Questions tagged as 'sql-server'

1
answer

How to use LEAD and LAG using a condition

My question is, if I can use LAG and LEAD, using a condition in the query, for example: I have the zip column .. I want to get the value of the next line, and the value of the previous line in that same column. I'm working with C # and SQL...
asked by 29.04.2014 / 18:38
1
answer

Backup Database SQLServer

I know that to perform a backup in SQL Server just use: BACKUP DATABASE nome_database TO DISK = 'endereco\nome__arquivo.bak' But does anyone know how I back up all Databases together? Each in a .bak ?     
asked by 10.11.2014 / 21:24
1
answer

Is there a command to change a user-created type in Sql Server?

I created a type in my Sql Server database: CREATE TYPE [dtNumero] FROM [numeric](18, 5) NOT NULL Is there a command for you to change this type, for example precision?     
asked by 14.11.2014 / 12:17
1
answer

Query to update field from one table based on another

Good morning, I need to update the values of one table based on the values that are in another. I need the first table to update only the data contained in the second, for example, in the first table I have 3,000 items and in the second 330,...
asked by 04.01.2019 / 12:29
2
answers

Rows in Columns without Column Defaults - SQL Server

Hello, I'm having trouble turning rows into columns in SQL Server . I could not write anything yet ... I thought of PIVOT , but since it's not always the same amount of columns, I can not think of how to do ... I have these 2 t...
asked by 27.12.2018 / 14:50
1
answer

Error trying to import .bak file from Sql Server on Linux

I am very new to SQL Server and am trying to import a .bak file from a backup that came from another server (Windows) on Linux (Linux mint 19) The command I used on the terminal was this : sqlcmd -S localhost -U SA -Q "RESTORE DATABASE [de...
asked by 25.12.2018 / 16:09
1
answer

NodeJs query in SQL Server

Hello everyone, I need to do a filtered query for days in SQL in a NodejS application, but during the POST that is when I make the NodeJs filter I am accused of a value conversion error. When I run get get myself to retrieve the values of the Dat...
asked by 21.09.2018 / 17:17
2
answers

Error trying to establish connection between SQL Server 2014 and Visual Studio

I'm having trouble connecting to Visual Studio 2010 [c #] with Sql server 2014. I followed some tutorials but I was not successful. Why is such a mistake occurring?     
asked by 18.06.2014 / 16:29
1
answer

Count and group by day

SELECT loc.loc_pac as registro, datediff(dd, pac.pac_nasc, getdate()) as 'dias' from loc with (nolock), pac with (nolock), str with (nolock) where loc.loc_pac <> '' and (loc.loc_pac = pac.pac_reg) and (loc.loc_str = str.str_cod) order...
asked by 29.06.2018 / 02:27
1
answer

Assign execute command to a variable

I need the return of the execute command to be assigned to variable @PAGO because I will insert it into a temporary table only what returns is the script, not the value. DECLARE @COMANDO_COMANDO_PAGO VARCHAR(2000) SET @SITUACAO = 'PAGO'...
asked by 12.10.2014 / 19:59