Questions tagged as 'sql-server'

1
answer

Make query not showing some results

I have a CPF table where the CPF's are registered. I need to make a SELECT where I display all the registered CPF's, minus 3 CPF's. Something like: SELECT * FROM cpf WHERE cpf_id <> '111.111.111.11,222.222.222.22,...
asked by 20.01.2016 / 13:38
3
answers

How to perform UPDATE with ORDER BY on sql server?

I would like to perform an update ordering the results of it, so I wanted to run an update like this: UPDATE pessoa SET nome = 'Jose' WHERE sobrenome LIKE '%Betalla%' ORDER BY nome But when I try to perform this update, an incorrect syntax...
asked by 29.02.2016 / 19:53
3
answers

Copy data from one table to another without typing field by field

Does anyone know the SQL command that I copy data from one table to another table, without explicitly specifying all fields in the original table? I know there is a way but I forgot how it does and I could not find it on the net, if anyone knows...
asked by 08.03.2016 / 20:40
2
answers

Query with Datetime Sql and C #

I'm trying to get the patient back to me for a certain day and time in the following command: SqlCommand cmdSelect = new SqlCommand("select DISTINCT P.nome,P.codPaciente, M.codMedico, C.descricao from Consulta as C " + ", Medico as M, Pacient...
asked by 15.11.2018 / 21:19
1
answer

How to read this JSON correctly? MSSQL and Node

{ "recordsets": [ [ { "IdUsuario": 5152490, "strNome": "Roberto ", "IdPapel": 1 }, { "IdUsuario": 5152490, "strNome": "Roberto ", "IdPapel": 3000001 } ] ] I'm...
asked by 30.11.2018 / 18:03
2
answers

How to create a condition that does not include the month of December?

I'm creating a condition to be run before the month of December, that is, it only runs in the January period of November . IF (SELECT TarFechamento FROM Tarefa WHERE TarID = @Tarefa) < '01-12-2017' I put it like it was in the year of...
asked by 17.10.2017 / 19:06
2
answers

Higher value comparing rows

I'm using SQL Server 2008 R2 and I have the following table: ID NUMERO NOME MODELO --- ----------- ------ ------- 1 12 A 777 2 23 A 777 3 05 A 777 4 45 B 999...
asked by 24.04.2018 / 16:43
1
answer

GROUP BY in query with column by subquery

I have the following select: SELECT A.CARRO, (SELECT TOP 1 VALOR FROM tab2 B WHERE B.DATA <= A.DATA ORDER BY B.DATA DESC) VALOR FROM tab1 A    In (SELECT TOP 1 VALOR FROM tab2 B WHERE B.DATA <= A.DATA ORDER BY B.DATA DESC) wi...
asked by 08.08.2018 / 16:26
1
answer

Generate number using identity

Is it possible to generate a number before writing the record to the database? Use field identity of SQL Server 2014. Work with Delphi Berlin.     
asked by 23.08.2017 / 16:19
2
answers

How to get value from a database column using C #

I have a web application that uses these 3 tables: Client: CREATE TABLE CLIENTE( ID_CLIENTE INT PRIMARY KEY, CLIENTE VARCHAR(50), ENDERECO VARCHAR(50), CIDADE VARCHAR(30), CEP VARCHAR(9), UF CHAR(2) ); Order: CREATE TABLE PEDIDO (...
asked by 02.12.2017 / 15:13