Skip to main content
The 2024 Developer Survey results are live! See the results

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
0 votes
0 answers
2 views

Trying to delete 2 id table using union

I am trying to perform a delete on a table that has 2 id's with the differences of a view that I am using 2 ids on as well. Here is how I am finding the differences in Id's: Union of differences. Let'...
jasonc's user avatar
  • 229
-1 votes
0 answers
7 views

Using T-SQL for extracting from JSON

I am trying to extract data from the following json and pivot the data in "rows" to columns. { "tables": [ { "name": "PrimaryResult", "...
James's user avatar
  • 143
0 votes
0 answers
23 views

SQL Scan vs Seek when using OR in where criteria

Consider the following two queries from the AdventureWorks database. The where criteria is entirely on indexed columns. If you use OR criteria both tables get a full table scan on them. In the second ...
J. Moore's user avatar
0 votes
0 answers
36 views

How to create a file in another server using T-SQL

I have 2 servers; one server hosts a SQL Server (which is a Windows machine), and the other one is a linux system. I want to export the data from the SQL Server instance to linux system. While I was ...
kalyan4uonly's user avatar
0 votes
1 answer
33 views

How to query for an amount when it changes values base on a record (account#)

I am trying to query for an amount when it changes base on a record. For example the below table. I want to query for the rows with a (****). I want to know whenever the balance changes for each acct. ...
user2654626's user avatar
0 votes
0 answers
20 views

Why am I receiveing this collation error in .NET Framework 4.5?

Currently I am analyzing old solutions in my company and it we get following error message randomly: A .NET Framework error occurred during execution of user-defined routine or aggregate "...
Paglo's user avatar
  • 1
0 votes
1 answer
80 views

COMMIT TRAN not working in SQL Server 2019

I am working in an environment where I run the code below and SSMS says that the command was executed successfully. However, when I try to close the window it says that I have uncommitted transactions....
TheMortiestMorty's user avatar
-3 votes
4 answers
90 views

Removing duplicate number sets from a table

I am trying to find out how I can see in my table where the same set of numbers appears. Eg. I have a table with 10 columns numbered 1 -10. each column has a different number from 1 - 10. I want to ...
AlwaysThatGuy's user avatar
-1 votes
0 answers
27 views

Permissions disappear on object while using ALTER SCHEMA TRANSFER

We create a new stored procedure on any request for ALTER, by adding a suffix with "_V1","_V2", etc. In this way we can hold a backward compatibility between the application and ...
Sharon Rimer's user avatar
-1 votes
1 answer
44 views

Filter in T-SQL by many elements - efficient way

I want to use in where statement filter on many elements (over 100). For filter on few elements I normally use IN: SELECT * FROM t1 WHERE Product IN ('a', 'b', 'c') But what if there is over 100 ...
Jan Jankowski Janek's user avatar
-1 votes
2 answers
76 views

SQL rollup to add a total row for multiple columns

I am using the employee data set from Kaggle - Dataset I created a pivot table on top of this for EmployeeClassificationType and EmployeeStatus with pivotTable as ( select ...
Vinita's user avatar
  • 1,842
0 votes
2 answers
94 views

Calculate duration using T-SQL [duplicate]

I have a table containing columns Date and PumpStatus like this: Date PumpStatus --------------------------- 1/1/24 0:15 Running 1/1/24 1:25 Stop 1/1/24 2:21 Running 1/2/24 12:...
A H's user avatar
  • 3
0 votes
2 answers
101 views

Combine table columns into one unique value (as input for HASHBYTES)

Objective I want to combine the four columns of a row into one value, named COMBINED_VALUE. These strict rules apply: Two rows with the same column values in the same order must produce the same ...
Der U's user avatar
  • 3,314
-3 votes
0 answers
85 views

Unable to join the cte Throwing runtime error [closed]

I was solving a question in LeetCODE and I wrote the following query: WITH TotalCount AS ( SELECT COUNT(*) AS TotalCountOf FROM Register ) SELECT R.contest_id, ROUND((CAST(COUNT(R....
Sarika Ramachandran Nair's user avatar
-1 votes
1 answer
78 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 ...
ATL-JP's user avatar
  • 35

15 30 50 per page
1
2 3 4 5
4891