|
I want to pass my [Domainusername] as string . And if i pass my database name as string , how to execute the below line. because it doesnt accepts string? How to overcome the above problem?
(comments are locked)
|
|
You could use dynamic SQL. This isn't as good as the best way to use sp_executesql (that would involve passing in the parameters, but you would be right back where you started), but the quotename will help protect you from potential SQL injection attacks. If you do end up using dynamic SQL to do this, be sure you have read Erland Sommerskog's article on the subject, as well as Kim Tripp's article on the same subject. thanks ... i think, i need to groom my basics more and more
Jun 08 '11 at 04:28 AM
Bhuvans
(comments are locked)
|


can you post the exact sql you are using including the defintion and setting of the domainusername variable?
As for the USE statement - what else are you trying to achieve here - you could use
execorsp_executesqlbut the context would only last until the statement completed - it wouldn't change your working database in the calling context.yes u r right