Tuesday, 10 July 2012

dynamic store procedure call

ALTER PROCEDURE ams.Uselection
    (
    @TableName varchar(50),
    @Value varchar(50),
    @Text varchar(50)
    )
   
AS
declare @sql varchar(max)
BEGIN
 SET NOCOUNT ON
 set @sql=('select '+ @Value +','+ @Text +' from '+ 'ams.'+@TableName)
exec(@sql)
 set  NOCOUNT ON
END

No comments:

Post a Comment