Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Retrieving a value
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Retrieving a value
Divers
Thread ID:
00728752
Message ID:
00728752
Vues:
47
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

Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform