2/12/2023 0 Comments Tsql cursors![]() DECLARE A CURSOR DECLARE CUR CURSOR DYNAMIC FOR Select CustomerID,CustomerName,StreetAddress,City, State from dbo.Customer Set CustomerName= 'NO NAME' -Cursor Script Declare INT Declare VARCHAR (100) Where CustomerName in ( 'Aamir Shahzad', 'M Raza') Select 'John Smith', 'Test Street Address', 'New York City', 'NY' -Delete Records Delete from dbo.Customer Insert NEW Record Insert into dbo.Customer Select 'Aamir shahzad', 'Test Street Address', 'Charlotte', 'NC' Union Select 'M Raza', 'Test Street Address', 'Charlotte', 'NC' Select * from dbo.Customer Go -Insert couple of Records in Sample Table Insert into dbo.Customer drop table dbo.Customer Create table dbo.Customer ( Script for Dynamic Cursor in SQL Server used in the video as well. ![]() This type of Cursor is helpful when we want to extract the records from original table/s while cursor is open and we are still in process of modification of data or inserting new records and want to include them in cursor result set to perform operation.ĭynamic cursors are scrollable (First,Last,Prior,Next,Relative) but absolute option does not work with dynamic Cursors. The dynamic cursor will fetch the changes (insert,update or delete) on each fetch while cursor is open if any modification happened to original data in table/s. ![]() Cursors are the objects those allow us to access the data row by row from result set.ĭynamic Cursors are update-able.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |