Questions tagged as 'sql-server'

1
answer

SELECT operation in PHP with SQL Server 2008

Starting in PHP with SQL Server 2008. I'd like to know what's wrong with my code. <?php $serverName = "DESKTOP-B8EB4SG\SQLEXPRESS"; $connectionInfo = array( "Database"=>"contas", "UID"=>"sa", "PWD"=>"123456" ); $conn = sqlsrv_conne...
asked by 29.04.2018 / 22:18
1
answer

Select to get 2 columns constraint

I have a PERSON table that has field A and B that form a UNIQUE . I squeeze this select to return the name of the constraint : SELECT DISTINCT COL.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS Tab, INFORMATION_SCHEMA...
asked by 06.04.2018 / 20:29
1
answer

datetime vs dateime2, which one is the best?

I'm implementing a new project, using EF6 CodeFirst , EF6 creates my Sql-Server database, with date columns like datetime . What would be the difference between datetime and datetime2 , and which one is most likely to be used?     
asked by 06.04.2018 / 15:08
2
answers

Turning rows into columns in SQL [duplicate]

I have the following Query: SELECT distinct finmovem.num_transacao ,finempe.codigo_orgao ,finempe.cod_reduzido ,finempe.num_empenho ,finempe.data_empenho ,finempe.nome_fornecedor ,finempe.valor_...
asked by 12.04.2018 / 18:40
1
answer

SQL Server - count records by combination

I need to query the sql server so that it identifies to me when the 1,2 and 3 or 2 and 3 combinations of the "desc" column are present for repeated values of the "cod" column, the result should be returned as 1 for found and 0 not found. Does an...
asked by 25.04.2018 / 18:47
2
answers

Trigger condition

About the following trigger: CREATE TRIGGER [dbo].[TG_TESTE] ON [MINHABASE].[dbo].[TB_DOCUMENTOS] AFTER UPDATE AS DECLARE @ID INT DECLARE @DOC INT DECLARE @QTD FLOAT SELECT TOP 1 @ID = ID, @DOC = DOCUMENTO, @QTD = QUANTIDADE FROM d...
asked by 24.04.2018 / 13:41
1
answer

Error: Must declare the scalar variable

Can anyone help me with this? Must declare the scalar variable "@hospitalId". PendingController: public async Task<ActionResult> Index() { if (!Cookies.Exists("hid")) return RedirectToAction("Index", "Login", new { are...
asked by 22.03.2018 / 21:53
1
answer

Listing based on query in bank

First of all, I apologize if the question is vague, since it is a very broad topic. Today I have a system of registration and consultation of students, where the query is made exclusively by CPF, since it is a unique identifier and a constrai...
asked by 23.03.2018 / 19:07
3
answers

Bring more than one row in a SubQuery Sql Server

I'm working with 2 queries and would like a way to put the 2 in one, but I'm having trouble. I have the following example: Table T1: CD PF Data Total 1 JSL001 15/03/2018 100 Table T2: ID PF...
asked by 15.03.2018 / 20:58
2
answers

How do I count the number of items in a field repeated?

I have a table with the field CtrlChargeNum that has the log of the number of the load of a truck. I need to make a query that brings the total of that field. Until I got the query, see: SELECT COUNT (*) CtrlCargaNum FROM CTRL_CARGA WHERE Ct...
asked by 15.03.2018 / 20:48