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.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 How to use sp_MSforeachdb

Author  Topic 

montu
Yak Posting Veteran

60 Posts

Posted - 2008-02-19 : 01:00:06
need help-------------
i understand sp_MSforeachdb system stored procedure can be used to do the same task on all the databases. but when i tried this what i does execute that task/command number of times the available databases on same database instead execute that task once on each database.
this is what i was doing
use master
exec sp_msforeachdb @command1 = "exec sp_grantdbaccess @loginame ='test',@name_in_db = 'test'"
GO

can some one ther please help me how i can execute this for each database

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-19 : 01:23:05
Refer
http://www.databasejournal.com/features/mssql/article.php/3441031

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -