Reply to Re: Dynamic SQL does not work!

Your name:

Reply:


Posted by Erland Sommarskog on 02/08/07 22:39

SQLJunkie (vsinha73@gmail.com) writes:
> Thanks everyone for the replies. The following example is fine for
> generic SPs:
> SELECT @SPname = @DatabaseName + '.dbo.SPName'
> EXEC @SPname
>
> But what if I have to run SPs like SP_updatestats etc? then it will
> not work.

Au contraire, it will work just fine! If you say:

EXEC mydb..sp_systemprocedure

the system procedure will execute in the context of mydb.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация