Questions tagged [t-sql]
T-SQL (Transact Structured Query Language) is the extension of SQL functionality supported by Sybase ASE and Microsoft SQL Server. Do not use this tag for MySQL, PostgreSql, Oracle(Pl/SQL) related queries. Please note that SQL code which is being written using LINQ will not also be the part of this tag. This tag specifically created for advanced SQL programming using Microsoft SQL Server.
t-sql
73,338
questions
-2
votes
1
answer
63
views
Calculate days in between status change
I'm not sure how to code to get the result I'm looking for. I hope the community can point me in the right direction. I need to run a report against the Rent History table, and I expect the report to ...
1
vote
1
answer
55
views
I am trying to insert randomly generated numbers into an empty table using a cursor
I am trying to insert randomly generated numbers into an empty table using a cursor but I want it to go through all possible combinations with out having duplicates of the same number and I want to ...
0
votes
0
answers
23
views
SQL 2012 Dynamic T-SQL code is not returning any data
I'm trying to create a trigger which will automatically store changes to any data as a string (but only the data that has changed - output would be {firstname:john,surname:doe}), this string would ...
-3
votes
0
answers
52
views
Issue with modulus operator in dynamic SQL [closed]
I am trying to execute the following example query through dynamic SQL (let's not get into why it's dynamic), but I cannot get it to consistently execute correctly.
If I substitute % with %% I get ...
0
votes
0
answers
34
views
How to update multiple records with the same values but using different values in the where clause [duplicate]
I have to update a large number of rows with the same values, but the values in the update where statement would be different for each row that needs to be updated.
For example col1 and col2 need to ...
0
votes
1
answer
66
views
T-SQL Pivot with Square Brackets
I have a table of key-value pairs that I want to pivot.
Unfortunately, some of the records contain square brackets. How can I transform or adopt my SQL statement to work with square brackets?
Thanks!
...
0
votes
0
answers
22
views
How can I force SSMS to drop a temp table that has new columns? [duplicate]
I often use temp tables while researching data, and sometimes I'll create the table and then try to drop it and create a new one with more/different columns. SSMS does not like this. For example, if I ...
-4
votes
1
answer
75
views
Find occurrence of transport status
I have 2 Tables "Transport_Status" and "Receipts" where the id number is the key and can occur in Transport_Status more than once.
I want to protocol the transmission of the ...
0
votes
1
answer
37
views
How to identify Transaction tables within a SQL database?
I need to identify which tables within a sql database are transactional, in order to diferentiate whether the load will be full or incremental in Azure Data Factory moving data into a parquet file in ...
0
votes
1
answer
110
views
Optimizing SQL query - joining views of views is extremely slow [closed]
Following question pertains to Microsoft SQL Azure (RTM) - 12.0.2000.8. The XML I got from Azure Data Studio does not work on Paste The Plan website, so I am sharing the raw XML instead.
I have a ...
-1
votes
0
answers
68
views
Invalid Column with view and multiple schemas [closed]
I have two tables and two schemas created. I've already have a VIEW using both tables and both schemas. But when I try to modify it I receive the error invalid column name. But if execute the query (...
0
votes
1
answer
85
views
Rewrite this stored procedure so that it passes up this error through the output variable?
I moved a stored procedure from one database to another and that went fine. I then went to run it and got these errors:
Msg 208, Level 16, State 1, Procedure dbo.myStoredProc, Line 159 [Batch Start ...
-1
votes
0
answers
61
views
How to transpose rows into columns and ensure all other data matches with the record
I am repeating the question that was previously answered. I need further transposing for columns in the database, hence, I am reposting the question:
Parsing First Name and Last Name
Example below, a ...
-2
votes
1
answer
78
views
Recursively call the REPLACE function without recursion when the search_expression values are in subsequent rows?
Is it possible to recursively call the REPLACE function, without recursion, looping, dynamic SQL, UFNs?
Update: Re-wrote the entire question.
I'd like to be able to select a string with all the [...
-1
votes
0
answers
37
views
Convert datetime2(7) from 2012-07-29 10:53:33.0100000 to 29/07/2012 10:53:33 into my stored procedure
I need to convert datetime2(7) from 2012-07-29 10:53:33.0100000 to 29/07/2012 10:53:33 in my stored procedure in SQL Server.
I have this problem with t888_fecact and t888_feciof.
I tried this, but ...