Questions tagged as 'sql-server'

1
answer

Replace in Date within a FOR

I want to return the last 12 months, the day should come as 01 and need month and year. ex: 2014-12-01 2014-11-01 NOTE: I placed yyyy-mm-dd only by a pattern of mine. I'm doing this: DECLARE @count INT DECLARE @Data_Atual DATE SET @cou...
asked by 08.01.2015 / 19:05
3
answers

Problems with LEFT JOIN

I'm breaking my head a few days ago with SQL on something that should be pretty simple, but I can not figure it out. I want to get all the data in the [NumOrdem] table including those that are not in the [ItemNotes] table with the following S...
asked by 10.12.2014 / 20:53
1
answer

Error in Sql Server: is not a recognized function name

I have two functions in the sql server that are not being recognized by the database -- Não loga conexões de usuários de sistema IF (ORIGINAL_LOGIN() IN ('sa', 'AUTORIDADE NT\SISTEMA', 'NT AUTHORITY\SYSTEM') OR ORIGINAL_LOGIN() LIKE '%SQLServe...
asked by 15.04.2016 / 17:28
1
answer

Generate bank backup via application

In my project, I connect to the database. Is there any way I can back up my database via ASP.NET MVC 5 and save that backup directory, either in the project root or in a folder in a more secure place? The database I use is SQL Server Ex...
asked by 27.11.2014 / 13:28
1
answer

Get Gaps in a SQL Sequence

Hello, I have a select today that returns the following result: I make another select that returns a value, 5 for example. I would need to know which numbers are not between the number 1 to the number 5. In my case I would need the foll...
asked by 20.12.2018 / 17:05
1
answer

How do I change 2 or more columns at the same time in Sql Server 2014? (ALTER TABLE / ALTER COLUMN)

How do I change 3 columns at the same time in the SQL SERVER table? I want to change COLLATION , but could be something else. I tried: ALTER TABLE dbo.SIX_POSTO ALTER COLUMN VIS_DS VARCHAR(200) COLLATE Latin1_General_CI_AI NOT NULL...
asked by 04.01.2019 / 21:54
2
answers

Stored Procedure with output parameter being the Id of the last insert. W#

Hello, I'm performing an insert into a table, but I need it to return the ID you just entered. I searched the OUTPUT command but could not solve my problem. I need to do all this using procedures, ie I also need to know how to "get" this...
asked by 13.05.2014 / 21:44
2
answers

List column

I worked with PostgreSQL for a long time and now with SQL Server I have been missing some of the features that made life much easier. I have for example a table that one of its columns should be a list of strings , that is, an array of varch...
asked by 18.08.2018 / 23:06
1
answer

Field condition with subquery

Select example: SELECT campo1, (ROUND(((t3.quantidade * t2.distancia * (SELECT TOP 1 valor FROM frete WHERE datainicio <= t1.dataemissao AND tipo = t4.tipo ORDER BY DATAINICIO DESC)) - (t1.fretevalor - t5.pedagios)) / (SELECT TOP 1 valor FR...
asked by 08.08.2018 / 20:43
1
answer

Error: SQL Server String or binary data would be truncated

I have the variable @numero1 which has the following result:    020000000000720000018 But at the time of the update it gives the error:    SQL Server String or binary data would be truncated declare @g1 varchar(50) declare @n...
asked by 29.08.2018 / 19:44