Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retrieving a value
Message
 
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00728752
Message ID:
00729938
Views:
22
Joe,

This works for me
DECLARE	@COLNUM smallint
SET @COLNUM = 3
DECLARE @TESTFIELD varchar(100)
DECLARE @RESULT varchar(100)
DECLARE @Sql NVARCHAR(512)
USE Northwind
set @TESTFIELD = COL_NAME(OBJECT_ID('dbo.Employees'),@COLNUM ) 

SET @Sql = 'DECLARE Employee_Cursor CURSOR GLOBAL FOR SELECT ' + 
	@TESTFIELD + ' FROM Northwind.dbo.Employees'

EXECUTE (@Sql)
OPEN Employee_Cursor
FETCH NEXT FROM Employee_Cursor into @RESULT
PRINT @RESULT

CLOSE Employee_Cursor
DEALLOCATE Employee_Cursor
< snip >
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform