Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
ALTER PROCEDURE dbo.result_count @name nvarchar ,@other nvarchar,@zezo nvarchar /* ( @parameter1 int = 5, @parameter2 datatype OUTPUT ) */ASdeclare@id_bill intset @id_bill=(select max(@name)+1 from counter) insert into counter (@zezo) values (@id_bill) i want to pass columen name as parameter put this give me wrong formatzezo
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2008-06-15 : 09:01:07
you need to use dynamic sql if you want to pass column name as a parameter.
ALTER PROCEDURE dbo.result_count @name nvarchar ,@other nvarchar,@zezo nvarchar/*(@parameter1 int = 5,@parameter2 datatype OUTPUT)*/ASdeclare @id_bill int,@sql varchar(8000)set @id_bill=(select max(@name)+1 from counter)set @sql='insert into counter (' + @zezo +')values (' + @id_bill + ')'exec (@sql)
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2008-06-16 : 09:15:23
www.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail