Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use variable tablenames in SP
Message
 
 
To
26/07/2011 12:08:49
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2008
Application:
Desktop
Miscellaneous
Thread ID:
01519190
Message ID:
01519215
Views:
22
>>In SQL Server you must use dynamic SQL for this purpose, e.g.
>>
>>declare @SQL nvarchar(max)
>>
>>set @SQL  = 'select * from ' + quotename(@TableName) + ' where UserName = @cUser'
>>
>>execute sp_ExecuteSQL @SQL, N'@cUser varchar(20)', @cUser
>
>Thanks, that looks really weird for a FoxPro guy, doesn't it? How did you ever get used to that?

I spent some time in MSDN T-SQL forum and for me now writing VFP SQL query takes a bit of a time - writing SQL queries comes naturally.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform