Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retrieving a value
Message
From
02/12/2002 14:59:33
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Retrieving a value
Miscellaneous
Thread ID:
00728752
Message ID:
00728752
Views:
44
I need to pass a column number to an SP and get the value of that column from a cursor. Currently I have the following;
CREATE PROCEDURE AAA 
	@COLNUM smallint
AS

DECLARE @TESTFIELD varchar(100)
DECLARE @RESULT varchar(100)

set @TESTFIELD = COL_NAME(OBJECT_ID('Northwind.dbo.Employees'),@COLNUM )

DECLARE Employee_Cursor CURSOR FOR 
SELECT @TESTFIELD FROM Northwind.dbo.Employees

OPEN Employee_Cursor

FETCH NEXT FROM Employee_Cursor into @RESULT

PRINT @RESULT

CLOSE Employee_Cursor
DEALLOCATE Employee_Cursor
GO
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Next
Reply
Map
View

Click here to load this message in the networking platform