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

All Questions

Tagged with
0 votes
0 answers
22 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
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
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
-3 votes
0 answers
54 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 ...
Golden Tuna's user avatar
0 votes
1 answer
71 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! ...
METZGERR's user avatar
-4 votes
1 answer
79 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 ...
verklixt's user avatar
  • 703
0 votes
1 answer
115 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 ...
tubular's user avatar
  • 116
-1 votes
0 answers
71 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 (...
StandardIO's user avatar
0 votes
1 answer
93 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 ...
TheMortiestMorty's user avatar

15 30 50 per page
1
2 3 4 5
3475