Questions tagged as 'sql'

1
answer

Composite update

I have a table pessoas where, I have several fields referring to the person's registry, One of these fields is PES_NUMERO , which is nothing more than the code of the person in the system, well, I have another field called EST_N...
asked by 22.08.2016 / 21:43
1
answer

Calculation of string occurrence

I have a table with 3 columns id , nome and voto . They are populated with many records, and I need a calculation that returns the name with the best "balance" of votes . The voto column can only receive values like 'y...
asked by 22.08.2016 / 19:12
1
answer

Check difference between unlisted results and identify which day of the week is the date

I have the following query: SELECT V.CHAPA, F.NOME, V.DATA, MAX(V.SEQUENCIALBATIDA) AS BATIDA FROM ARELBATIDATRANSITOVIEW AS V LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA = F.CHAPA WHERE...
asked by 19.10.2016 / 21:55
1
answer

Running Data Bank SQL Server External HD

I'm starting to build a Web application using SQL Server and I talked to my client to make the database backup available, avoiding access to their production base, since it does not have a certification base. The 10GB .bak was generated where it...
asked by 19.10.2016 / 02:54
1
answer

How to use having together with view in sql server

When trying to use HAVING in a SQL query is returning the following error: Mensagem 8121, Nível 16, Estado 1, Linha 15 Column 'V_DADOSFUNC.FILIAL' is invalid in the HAVING clause because it is not contained in either an aggregate funct...
asked by 18.10.2016 / 20:23
3
answers

Error using HAVING in query with date / time

I have the following query: SELECT ROW_NUMBER() OVER(ORDER BY V.DATA ASC) AS ID, V.CHAPA AS CHAPA, F.NOME AS NOME, V.DATA AS DATA, CASE WHEN V.BATIDA IS NULL THEN 0 ELSE V.BATIDA END AS IS_NULL FROM...
asked by 20.10.2016 / 20:44
3
answers

SQL - Doubt in a query

Thanks to Motta's help I managed to get into a satisfactory query but I ran into another query because I need to list only the smallest record by cod , and count the amount of the menorregistro column by name. > Could someone help...
asked by 28.07.2016 / 17:54
2
answers

How to create a FOREIGN KEY using uniqueidentifier in SQL Server

Hello, I'd like some help. I have a table in SQL called Client, which has as primary key a type uniqueidentifier Ex: Create table Cliente ( ClienteID uniqueidentifier not null, Nome varchar(50) ) I'd like to know...
asked by 19.07.2016 / 17:20
3
answers

INSERT within a SELECT - SQL Server

I need to do an INSERT within a SELECT in some cases in my Query. An example of how I need to: SELECT IdTabela, Nome, CASE WHEN IdTabela > 10 THEN INSERT INTO TabelaExemplo (IdTabelaExempl...
asked by 19.07.2016 / 22:51
1
answer

Write log of a field only if it is insert (trigger SQL Server)

I have a trigger that fires when insert / update FOR UPDATE, INSERT I check if the field has changed with: if update (nome) --faça algo How do I know if I am inserting a record in the table to be able to record a log?     
asked by 20.07.2016 / 15:42