Questions tagged as 'sql-server'

2
answers

How to format a DateTime field in the Brazilian format dd / MM / yyyy?

I would like to format the DataAfr and DataTrm fields of type DATETIME , in Brazilian date format dd / MM / YYYY instead of the American format yyyy-mm-dd hh: mm: ss SELECT e.NmrCnt AS [Contrato] ,e.NmrSeri...
asked by 21.09.2016 / 14:55
5
answers

Show all days between two dates

I need to display all the dates that exist between two defined dates. I do not need the information of the difference between these dates, nor of data that is in the interval between them, but rather display the dates for each day of the inte...
asked by 22.07.2015 / 20:00
4
answers

Generate sequential IDs without losing the sequence

By Identity do not want to, because it breaks the sequence if something happens. Max() + 1 , I find it very vulnerable and slow when I have many records. So I ask, is there a way that someone knows, that I can generate sequential n...
asked by 05.06.2014 / 20:33
4
answers

How to do select in 3 tables?

I need to do SELECT on two tables with relationship n to n , so I will have to make use of the middle table too, but I do not know how to do this. I'm using PHP and SQLServer database.     
asked by 23.11.2015 / 17:07
1
answer

How to round off time?

I have the following function that treats a time that comes from the bank: SELECT f.chapa AS chapa, f.nome AS nome, f.secao AS cod_secao, f.nsecao AS desc_secao, c.codigo AS cod_funcao, c.nome AS desc_funcao,...
asked by 10.02.2017 / 14:47
1
answer

How to remove spaces leaving only one?

Considering a variable with a text in SQL Server . How can I remove 2 or more spaces within the text? In this case leaving only 1 space. For example: '1 tigre, 2 tigres, 3 tigres' Should result in: '1 tigre, 2 tigres, 3 tigres...
asked by 16.05.2017 / 15:47
1
answer

Identify if a string is uppercase in sql server!

I have a field in a table that must be filled in all lowercase, but the user being user has filled some lines in uppercase. I want to identify which records are in order to request correction. How can I test if my string is all uppercase?   ...
asked by 02.06.2017 / 19:24
1
answer

Number of columns influence performance?

When we model a database, can the number of columns interfere with performance? Ex: Tabela1 possui 2 campos, 1 int pk e 1 nvarchar(50) Tabela2 possui 50 campos, 1 int pk e 49 nvarchar(50) Select used for both tables, regardless o...
asked by 27.10.2015 / 13:01
1
answer

What is the difference and advantages in using @@ IDENTITY and OUTPUT INSERTED.

I've always used @@IDENTITY to get the last identity value entered, as in the example below. create Proc [dbo].[Arquivos] @IdArquivo int, @IdArquivo_Out int output as begin Set Xact_Abort on Set Nocount on Begin Tran begin...
asked by 24.11.2015 / 16:52
3
answers

"Translate" MySQL query for SQL Server 2012

What is the SQL Server 2012 query that corresponds to the next MySQL query? REPLACE INTO schedule SET jobname = "sqldump" , last_exec_date = NOW()     
asked by 29.12.2016 / 05:51