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 |
scelamko
Constraint Violating Yak Guru
309 Posts |
Posted - 2007-04-15 : 08:58:41
|
Guys,I am trying compile below function where I pass tablename as variable.CREATE FUNCTION [dbo].[GetNextValue] (@tablename varchar(30) )RETURNS int ASBEGINdeclare @value inttruncate table @tablenameINSERT INTO @tablename (FNAME) VALUES ('SMITH')select @value = id from @tablenamereturn @valueENDI get the following messageMsg 1087, Level 15, State 2, Procedure GetNextValue, Line 7Must declare the table variable "@tablename".Any suggestions/inputs to get around this would be helpfulThanks |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
scelamko
Constraint Violating Yak Guru
309 Posts |
Posted - 2007-04-15 : 09:14:25
|
sorry for the fauxpassIs there a solution for this problemThanks |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-15 : 09:17:27
|
quote: Originally posted by scelamko sorry for the fauxpassIs there a solution for this problemThanks
use stored procedure. But first, what are you trying to do here ? Why do you need to pass the table name in dynamically ? KH |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|