My column "ColumnOne" in my table "MyTable" has values like this: Delimiter is character ‘-‘ |Something | |Something – SomeOtherThing | |Something – SomethingElse | |Something – Whatever | |OtherThing – | I want to update the values so eventually it look like this: |Something | | SomeOtherThing | | SomethingElse | | Whatever |… Read More Updating the left side of a string up to a delimiter
As an example I have a table in SQL Server : Id 1 3 5 and I have a list of values 1,2,3 What is the query to select values of my list not in the table. Expected result : Id 2 >Solution : Here are two approaches Using Not Exists Select * from string_split(‘1,2,3′,’,’)… Read More SQL Server query to select only values not in a list
I have a following table:- declare @tab table(name varchar(10),id int) insert into @tab values (‘A’,1),(‘B’,1),(‘C’,1),(‘D’,1),(‘E’,2),(‘F’,2) I need following output:- declare @tab1 table(name varchar(10),id int, cnt int) insert into @tab1 values (‘A’,1,4),(‘B’,1,4),(‘C’,1,4),(‘D’,1,4),(‘E’,2,2),(‘F’,2,2) select * from @tab1 I tried following query:- select name,id,count(*) as cnt from @tab group by name,id Thanks >Solution : Try this select name… Read More sql query for counting the records of particular id and show in column
I have a XML column in a SQL Server 2012 database table, and one particular element in the XML stores multiple values. The issue I have is that I don’t know what the max values of those child elements are. It could be 2, 3 or 10 etc. I need a way to extract the… Read More Parsing more than one value from XML element
In my SQL table, I have records. Some of them have FLAG Y/N. Now, when I run my query, I want to display first all the Y values and then N. Table details StuID …. StuFlag 1 …. N 2 …. N 3 …. Y 4 …. N 5 …. Y Now, when I execute… Read More Display first true and then false
I’m trying to write a script and do the following steps in my db. Read records (where CreatedDate = 06/06/2022 AND Status = Processed) from Daily_Proc table. Check if any particular record is also existed in Lit_Hold_Err table using ‘MID’ and ‘Source’ columns value. If a particular record is existed in Lit_Hold_Err table then update… Read More How to check with different table and update it in SQL Server
I need some help I need to calculate the total hours of each employee and also show all the dates of each employee in a same table. My Table is like below- Employee Date hours Rohit 06-03-2022 9 Rohit 07-03-2022 8 Rohit 08-03-2022 9 Rohit 09-03-2022 9 Rohit 10-03-2022 10 Rohit 11-03-2022 8 Rohit 12-03-2022… Read More How to calculate the sum of a column by individual category separately?