var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: how to use @tablename
i need to develop a stored procedue, in ehich i have to use variable table name.. as
but i m unable to do so..
Select * from @tableName
it says u need to define @tablename
heres da code
CREATE PROCEDURE validateChildId
@fid int output
SELECT @fid=fid FROM @tableName
where @childId= childId
@fid = 0
write Dynamic SQL
you need to write a Dynamic SQL Statement for this.
Declare @SQL VarChar(1000)
SELECT @SQL = 'SELECT * FROM '
SELECT @SQL = @SQL + @TableName
Exec ( @SQL).
Something like this.
Do let me know if you want the code for your scenario.
exec ('Select * from ' + @TableName)
...is, for its brevity and wanton violation of sound development principles, arguably the most concentrated example of bad code one could write.
I would no more encourage you to do this than I would recommend one brand of cigarettes over another.
i understand its the crudest way of writing code, if there's any other method which can solve this problem, please do let me know. I can Improve my knowledge too. :-)
I wasn't disparaging your code, which effectively solves the problem that was presented.
The solution isn't the problem. The problem is the problem.
It just isn't a good idea to develop applications with this type of functionality. It opens a gaping hole into the database that user's are free to jam anything into, intentionally or inadvertently.
Waqas needs to reconsider the design of his application.
I apologize if I inadvertently offended you.