|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cursors and Temp Table : in SQL Server1. Can I pass Parameter to a Cursor ???
2. Is it must to declare the Holding variable for a Cursor above it before opening ? 3. Can a temp table be update ? 1) Yes (see example below)
2) No (see example below) Cursor example: use pubs DECLARE @State char(2) set @State = 'UT' PRINT '-------- Utah Authors report --------' DECLARE authors_cursor CURSOR FOR SELECT au_id, au_fname, au_lname FROM authors WHERE state = @State ORDER BY au_id OPEN authors_cursor DECLARE @au_id varchar(11), @au_fname varchar(20), @au_lname varchar(40), @message varchar(80), @title varchar(80) FETCH NEXT FROM authors_cursor INTO @au_id, @au_fname, @au_lname print @au_id CLOSE authors_cursor DEALLOCATE authors_cursor 3) Yes (see example below) Create table #test (a char(1)) insert into #test values ('a') select * from #test update #test set a = 'b' select * from #test drop table #test Show quote "akpate***@googlemail.com" wrote: > 1. Can I pass Parameter to a Cursor ??? > > 2. Is it must to declare the Holding variable for a Cursor above it > before opening ? > > 3. Can a temp table be update ? > > |
|||||||||||||||||||||||