Questions tagged as 'tsql'

0
answers

Get Directory and number in a string in an irregular expression

I have a table that has all the address in a single column, but it is irregular. Here are some of the following: BR 459 KM 153 RODOVIA ITAJUBA MF KM 05 Rodovia MG353 2Km 55 RUA 37 QUADRA 4 LOJA 611 E 1621 Rua 13 de Maio 71C RUA 106 Nº07 RUA...
asked by 14.05.2018 / 20:25
2
answers

GROUP BY with 2 Tables

I need to do a select with JOIN on two tables but I can not group to not repeat the rows. Here is the SQL expression: SELECT Andamento.NumeroProcesso, Andamento.Chave, Andamento.Codigo, Andamento.DataAnda...
asked by 24.11.2017 / 13:54
5
answers

Group records per day

I have the following table ID | Início | Fim | Horas 333 | 01/01/2017 | 03/01/2017 | 5 333 | 02/01/2017 | 05/01/2017 | 1 333 | 05/01/2017 | 07/01/2017 | 3 333 | 01/01/2017 | 07/01/2017 | 6 I need a result like this...
asked by 12.01.2017 / 17:39
3
answers

Select last records sorted by 1 field

I have the following table structure The goal is to get the last 3 oldest records (oldest date) sorted by Name. I'm currently using subselect: Select * from (Select top 3 from TB order by Data desc) A order by Nome Are there an...
asked by 24.06.2015 / 13:57
2
answers

Query on all tables in the database

Is it possible to query all tables with the same column for their values? For example, I have the Bank named SGE , I have 230 tables in it, all these tables have the CodPRF column and I want Query to return all the results in th...
asked by 04.12.2017 / 18:50
3
answers

Convert nvarchar field (50) into datetime table SQLSRV

I need to change a field in the SQL database table whose format is in nvarchar(50) and saved values in date format 07/09/2017 , containing NULL values too! Do I need to convert this direct field in the database to datetime...
asked by 07.09.2017 / 16:14
2
answers

Convert hours "hh: mm: ss" to minutes in int format

I have the following function that calculates the 01:00 hours, returns 60 minutes.  but the sql column stores in time (0) 01:00:00 format, What about the error in my function, I do not know how to increment the code to calcu...
asked by 28.03.2016 / 05:28
2
answers

TSQL dynamic for multiple returns

I need to make multiple inserts that will depend on an existing result in a table like this: --CRIA TABELA #CONTATO CREATE TABLE #CONTATO( NOME VARCHAR(100) NULL, TELEFONE VARCHAR(50) NULL ); --INSERE 2 LINHAS NELA INSERT INTO #CONTATO...
asked by 22.04.2015 / 22:29
2
answers

Capture values from one table and insert them into another table

I have a temporary table that I fill in with the result of a given query. Now I need to go through the data of this temporary table, line by line, and pick certain fields and insert them into another table, and in that other table, generate a co...
asked by 19.12.2016 / 19:15
1
answer

How should data be selected from a table through joins?

By using SELECT to get the data of tabela_A by joining with tabela_B , normally, and assuming it to be the correct form, we use some of the JOIN commands. Ex: SELECT codigo, nome FROM tabela_A a INNER JOIN tabela_B b...
asked by 25.02.2016 / 20:41