Questions tagged as 'sql-server'

2
answers

Increase dblib connection timeout with PDO

In a connection to an external server ( MS SQL SERVER ), from another system with which I integrate some data, it is extremely slow, and thus the connection to the database gives error. How to increase the timeout of the PDB connection with...
asked by 05.09.2016 / 16:55
1
answer

Left Join or Not Exists

I needed to retrieve information that was in one table, but not in another. Searching found that NOT EXISTS would serve this purpose, but I saw that the Left Join has the same result: NOT EXISTS select pedido from logintegracao as A where...
asked by 09.12.2015 / 19:11
1
answer

Left join with lambda GroupJoin and with condition

How can I make a left join with some conditions using LINQ lambda expressions? In SQL Server I have this query: select usr.Id, usr.FirstName, usr.LastName, ex.Id from User usr left join Exam ex on ex.Id = usr.IdExam and (ex.Id is...
asked by 11.02.2015 / 20:02
1
answer

How to handle duplicate key error?

How do I handle duplicate key errors? I need to display message to user that "Item is already registered" Something like this: try{ //tenta inserir no Banco de Dados context.Produto.Add(_produto); context.SaveChanges(); }catch(exceç...
asked by 02.10.2015 / 01:26
3
answers

Convert rows to columns (Pivot?)

I have a table with 33 million phone records with the structure below: ccpf_cnpj ddd telefone tipo origem 11111111111 83 81021111 M SERASA 11111111111 83 87472222 M SERASA 11111111111 83 81023333 M TRANSUNION 11111111...
asked by 11.02.2016 / 13:05
3
answers

LEN function, know number of characters of a number

In the example below the result of the query instead of returning 7 is returned 5 . DECLARE @valor money = 10.6879 SELECT LEN(@Valor) The impression I get is that when the number is of type money , only 2 decimal places are con...
asked by 02.07.2018 / 20:54
2
answers

SQL - Restrict query data

Good morning, I have an app in WebForms that from two DropDownList gets data from a database in MS SQL Server 2012 . At first DropDownList it will display the name of several companies in the database with the fo...
asked by 15.04.2016 / 10:50
0
answers

How index selectivity works

Reading about indexes I recently came across the term "selectivity". Some places said that more selective fields should come first in the index, others say no or that it depends. I have the following table tbMovimentoConta abbreviation...
asked by 11.01.2017 / 17:25
2
answers

READPAST and NOLOCK What are they?

What is READPAST and NOLOCK ? I have seen quite a lot of the use of NOLOCK , but READPAST saw use now, pretty much the same way, ie. FROM dbo.table t WITH(READPAST) and FROM dbo.table t WITH(NOLOCK) But wh...
asked by 31.08.2017 / 19:55
4
answers

Calculate Total Hours, identifying equal time intervals

After breaking my head a little, I ask you to help me in the following situation: I have a problem in SQL (Sql Server 2005) of time calculation; Basically I have to calculate the sum of hours worked on technical drives. The issue is that a...
asked by 06.03.2015 / 15:41