3/31/2024 0 Comments Ms sql cursorsOnce each table is retrieved in a cursor we stored the in a variable.',' + as varchar(30)) + '-' + as varchar(30))įetch next from into = next from outer_cursor into = match_cursor Select top 100 id, stationid, trackid, date, matchtimestart, matchtimeend, streamfileįrom matches where trackid = order by MatchTimeStart ĭeclare outer_cursor cursor static local forįetch next from outer_cursor into = 0 The T-SQL code is given below in the form of a Stored Procedure.Īlter PROCEDURE. Obviously it makes much more sense to simply do a JOIN, but this code is more to show nested cursor looping than do anything particularly useful. The example T-SQL code shows how to iterate rows in matches and then fetch the track row for that track from the track table. matches – table which stores tracks matched in external dataĪs you can see in the table rows below, the Id field of the track table is the foreign key in the matches table in the form of trackId.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |