Questions tagged as 'sql-server'

1
answer

SQL Server vs. MongoDB - Disk Size

Today I have a very large table in SQL Server and it receives data all the time regarding some machines in the factory. This is causing a problem of heavy disk consumption, the size of the table does not stop increasing. If I pass this tab...
asked by 04.10.2018 / 14:08
1
answer

When Calculating quantity greater and less than Average returns error in SQL SERVER

In Columns: SUM(CASE WHEN cqd.queuetime < AVG(cqd.queuetime) THEN 1 ELSE 0 END) as 'Qtde < Média' e SUM(CASE WHEN cqd.queuetime > AVG(cqd.queuetime) THEN 1 ELSE 0 END) as 'Qtde > Média', returns the following error in SQL SERVER...
asked by 30.11.2018 / 14:05
1
answer

How to return what the customer bought / paid for?

I have the following tables: using JOIN CREATE TABLE tbCliente ( ClienteID INT IDENTITY(1,1) PRIMARY KEY, ClienteNome VARCHAR(50), ClienteTelefone VARCHAR(15), ClienteDataCadastro DATE) CREATE TABLE tbPagamento ( PagamentoID INT IDENT...
asked by 07.12.2018 / 22:52
1
answer

SQL Server Sum Sum Error on DAO Layer

I'm trying to show the result of SUM in the DAO layer, the query after the expected result, but in the field where the sum is shown, does not show an error. A procedure in Sql Server ALTER PROCEDURE [dbo].[RelatorioDcv] @dateInicio date, @d...
asked by 21.08.2018 / 16:56
2
answers

How to Automatically Name a CONSTRAINT Manually Created in SQLServer 2016

Hello, I'm creating a database and I need to create some compound indexes to optimize the bank's processing. The problem is that I do not want to have to name those indexes one-by-one. Normally, I create a table as follows: CREATE TABLE Usua...
asked by 22.08.2018 / 17:53
1
answer

How to add primary SQL Server key?

Good morning! maybe it's simple my question, but ... I would like to know how to add primary key in a table not being at creation time (CREATE), I know that when accessing the table in "object explorer" in the "design" option it is possible with...
asked by 01.08.2018 / 14:10
1
answer

When is it valid to use XACT_ABORT () in a script that is already using TRY / CATCH?

Assuming the following code: /* DROP TABLE #Teste; CREATE TABLE #Teste(id INT); INSERT INTO #Teste VALUES(1); CREATE TABLE LogErros(id INT IDENTITY(1,1) PRIMARY KEY, nomeTransaction VARCHAR(100), errorMessage VARCHAR(500), horaErro DATETIME) D...
asked by 31.07.2018 / 14:40
1
answer

Dynamic Questionnaire php SQL Server

Hello,  I am building a calibration tool (given a checklist the user needs to select the fields that agree (or not) with a link or script. Ex.: 1)Colaborador inicia o atendimento conforme diretrizes. a) conforme b) não conforme c) não se apli...
asked by 20.07.2018 / 22:30
3
answers

SQL bring result with repeated numbers of column all only the largest

Hello, I'm trying to get a data but I'm not able to filter it the way I need it, for example: select a.cod, a.nome, b.pedido, b.versao from cliente a inner join pedido b On a.cod= b.cod order by b.pedido Now the problem one version has mor...
asked by 15.05.2018 / 22:59
1
answer

How to improve this sql code?

I would like to improve this code so I DO NOT REPEAT THE SAME CODE IN THE TWO IFS. I am not in the process of using procedures because I see no need. DECLARE @Ordem VARCHAR (7), @Valor VARCHAR(10) SET @Ordem = 'E' IF @Ordem = 'E' BEGIN SELE...
asked by 30.05.2018 / 22:36