Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dynamic cursor

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-07-15 : 10:24:36
Wilfred writes "Is it possible to write dynamic cursor in Ms-sql if not how can i achieve this

declare @tb varchar(90)
select @tb='mydb.syscolumns'


declare tbfrom insensitive cursor for
select 'Column_name 1' = name,
'Type' = type_name(xusertype),
'Length' = length
from @tb
where id = @objtoid
and number = 0 order by colid

most appreciated"

X002548
Not Just a Number

15586 Posts

Posted - 2004-07-15 : 12:04:25
You can shoot yourself in the head with a shotgun...but it ain't easy


USE Northwind
GO

DECLARE @sql varchar(8000), @OrderId int
SELECT @sql = 'DECLARE myCursor99 CURSOR FOR SELECT OrderID FROM Orders'
EXEC(@sql)
Open myCursor99
FETCH NEXT FROM myCursor99 INTO @OrderId
SELECT @OrderId
CLOSE myCursor99
DEALLOCATE myCursor99




Brett

8-)
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-07-15 : 12:09:40
8 to 5000 Brett.
Go to Top of Page
   

- Advertisement -