Skip to content
Advertisement

Tag: cursor

Select all rows between dates

I have a #tmp table that looks like the following. It has a total of three lines. title receipt_date decision_date “It wasn’t as bad as I thought it would be” 2017-06-12 15:07:10.893 2017-06-23 09:37:31.667 “It wasn’t as bad as I thought it would be” 2017-07-11 10:35:24.337 2018-06-25 05:54:41.133 “It wasn’t as bad as I thought it would be” 2017-09-25 14:06:18.670

Reverse to STRING_AGG

Here is a sample data on which we are further processing. My question is, is there any exact reverse of the STRING_AGG function for SQL Server? Like I am merging using STRING_AGG with the following code I need to reverse the process but I had to use CURSOR so I am searching for an alternative solution. Below is the cursor

Concate string into temp table in cursor

I have a temp table structure @temp2 like this and would like to add the driverID column with a result like 5555, 68989 to do this, I use the cursor to loop another table look like this Here is the code sadly, I got the driverID column is null and would like to have finalized temp table look like this:

SQL Query, loop through data

I have a database with the following fields: UserID, DateRecorded and Score. A new entry is added to the table each time the score is updated. Here is an example of a user record: From the query I would like it to show me only the scores of all users with the earliest DateRecorded. Although not much familiar with cursors,

Advertisement