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.
Author |
Topic |
desikankannan
Posting Yak Master
152 Posts |
Posted - 2010-03-04 : 12:42:19
|
i can pass the table,column as in the procedureALTER procedure [dbo].[commondropdown](@tables varchar(50),@fldcode varchar(50),@fldname varchar(50),@fldparm varchar(50),@values varchar(50))asdeclare @setcounts varchar(50)set @setcounts = @valuesdeclare @sql varchar(1000)set @sql='select '+@fldcode+','+@fldname+' from '+@tables+' where '+@fldparm+'='+@setcounts+' order by '+@fldcodeEXEC(@sql)exec commondropdown 'mst_desc','desckey','descvalue','desccategory','slot' here 'slot' is not column its a value,but it show error once the execute procedure error messageInvalid column name 'slot' Desikankannan |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-04 : 12:52:56
|
what about this?set @sql='select '+@fldcode+','+@fldname+' from '+@tables+' where '+@fldparm+'='''+@setcounts+''' order by '+@fldcode------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-05 : 02:39:41
|
For more informations about Dynamic SQL, refer www.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|