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 |
ryoka012
Starting Member
20 Posts |
Posted - 2012-08-16 : 00:35:49
|
Hi have this table function is below query is acceptablecreate Function GetErrorCountOnTable(@Blno varchar(10),@Tablename varchar(50),@tableColumn varchar(50))returns tableasreturn declare @mytable varchar(50)set @mytable='Select * from'+ @Tablename + 'where'+ @tableColumn + '='+ @blnoexec(@mytable)Error Message say'sIncorrect syntax near the keyword 'declare'. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-08-16 : 00:44:19
|
you can't use dynamic SQL in a function. Use Stored Procedure instead KH[spoiler]Time is always against us[/spoiler] |
|
|
ryoka012
Starting Member
20 Posts |
Posted - 2012-08-16 : 00:45:46
|
Thanks for your prompt reply. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-08-16 : 10:47:04
|
Also why are passing object names as parameters?MadhivananFailing to plan is Planning to fail |
|
|
|
|
|