Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Retrieving a value
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00728752
Message ID:
00729938
Vues:
23
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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform