I am switching from MySQL to SQL Server for a new job and I have encountered something I don't quite understand as I haven't encountered something like this bef
I'm trying to store DDLs of some views and stored procedures in a separate table in the Dump database. There are too many similar databases on the server. But s
I'm trying to sum values inside a window function but I can't figure out have to prevent summing duplicates. Below is a snippet of the results I have right now.
I have data that looks likes: stu_id course_name staff_name 1 Economics - 3 Kuzma, Brian 1 History Hulings, Kreg 1 IHS IB Lit of Americ Duncan, Amy 2 Marine Bi
I have a table where as codes are present in the form of 78,7244,d345 by default few records are found where the codes are start with 0072 . I have to delete st
I only have only "read" permissions to the database. I am trying to pull data out of several tables with the same fields. I am pulling the table names from th
I am trying to query data from linked server. It is giving me the following error: TNS:listener does not currently know of service requested in connect descrip
I have two tables, Semester1 and Semester2. Semester1: StudentId SubjectId abc sub1 def sub1 ghi sub1 Semester2: StudentId SubjectId abc changedSub1 def sub1
I want to remove the first word from a large string in SQL Server. Input string: 931078027 BP 16:20:0:13 25 BAG 'B' CLASS Desired output: BP 16:20:0:13 25 BAG
I have a staging table which contains all varchar columns. I want to validate a date stored in the data column. Since my staging table contains all varchar colu
SQL Server 2017. Table OrderData has column DataProperties where JSON is stored. JSON example stored there: { "Input": { "OrderId": "abc", "Data": [
Select p.pnum, SUM(CASE WHEN P.NegativeScreen = 'Type99' THEN 1 ELSE 0 END) TotalDetected, SUM(IIF(P.IsPositive = 1, 1,0)) TotalP, SUM
I want to Create a table @tablename with data from a User-Defined Table Type but I get the error Must declare the table variable "@tablename" ALTER PROCEDURE
I'm trying to perform a PIVOT but getting an error. I'm trying to see which patients have more than one Interval session. The column is a text type. I attempted
I am trying to learn how to use transactions and error handling. Got stuck with custom error messages. The stored procedure generates badges for AdventureWorks
I have this sample table +--------+-------------+ | DBName | Description | +--------+-------------+ | A | Car | | A | Boat | | B
I have a SQL script with a function (function drops at the end of the script) and temporary table definitions and variables to process the data that gives me on
I need to get a comma separated list with quotes and I'm almost at that point but I get a list with commas but a leading space at the start bu
I am doing an outer join between two market data tables. The two tables have trading volume reported differently, therefor I need to query them separately and t
I am attempting to do a subquery which should work but I am missing something in the syntex. I am trying: select * from (select * from (select *, row_number