Updating the left side of a string up to a delimiter

Advertisements 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

sql query for counting the records of particular id and show in column

Advertisements 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… Read More sql query for counting the records of particular id and show in column

How to check with different table and update it in SQL Server

Advertisements 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… Read More How to check with different table and update it in SQL Server

How to calculate the sum of a column by individual category separately?

Advertisements 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… Read More How to calculate the sum of a column by individual category separately?