Questions tagged as 'tsql'

1
answer

Logical deletion of SQL Server records

We have the culture to only make logical exclusions in the application, maintaining 2 fields where 1 is the deletion date and another one that receives 'S' or 'N'. When we perform searches for undeleted records, we do something like: select...
asked by 13.02.2015 / 00:52
2
answers

How to do a dynamic update to all database tables for a specific column

How can I make a dynamic update to all database tables for a specific column common to all my tables? I'm thinking of using the catalog table to raise the database objects but how can I build the dynamic update for each table that the select...
asked by 12.02.2018 / 05:38
1
answer

Difference between days and minutes on Sql Server?

I have two columns of type datetime . I have tried in many ways to get the difference between them, but the number of days always goes incorrect. Example: Data1: 2018-01-17 17:00:00 Data2: 2018-01-18 10:00:00 Resultado obtido: 01 17...
asked by 18.01.2018 / 01:37
2
answers

T SQL Merge Two Lines in One

I have an id in common (103307) and would like to join two rows in one. From image 1 and leave as image 2. Is it possible?     
asked by 22.12.2017 / 21:38
1
answer

Create select to return last time something was different from zero

I have a table called Estoque , where it has the columns NOME_PRODUTO , DATA , among others. The idea is that when I make a SELECT Using the date as a parameter, all the products that were in stock on that day are return...
asked by 21.02.2017 / 01:55
2
answers

Sort in recursive query

In another question I asked I had found a solution but the sort order works only if the ID's are growing: USE TESTE GO WITH Niveis AS ( -- Membro âncora SELECT Id, IdPai, convert(varchar(1000), Nome) as Nome,...
asked by 27.02.2015 / 16:06
0
answers

StoredProcedure in SQL Server by passing a C #

I would like to pass a list of parameters to a procedure, how to do this process? I did some research and found that it is possible to create a TABLE TYPE and use it in the procedure parameters, but I could not use it, for example. CREATE T...
asked by 06.04.2018 / 17:35
1
answer

Import data from MS Access to Sql Server via code

I need to import data that is in an Access database via code to Sql Server. My software that is made in C # for many years has been integrated into an Access database. From now on we are migrating to Sql Server and the intention is that in the u...
asked by 30.11.2017 / 17:34
0
answers

How to make multiple mask replaces per T-SQL table field

I'm doing replaces of some texts (Mask) of a field of a temporary table. I'm replacing where text is searched for by a field from other tables. Example: SELECT TOP 1000 * INTO #TEMP_COMPL_L FROM TB_CONTRATO WHERE IDCAR_CON = 1 ALTER TABLE #...
asked by 13.07.2017 / 17:56
0
answers

Create Partition

I'm partitioning a table in my database, I created the function partition and the scheme partition. But when I go to the Create partition Wizard the Radiobutton Existing partition function is disabled even with function created. It's the sam...
asked by 05.08.2016 / 20:33