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 2000 Forums
 SQL Server Administration (2000)
 SQL scripting from a dos batch file

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-10 : 00:42:53
Ian writes "I need to add a Windows group to a database, grant them access and give them dbowner access rights, and i need to do it in a batch file. ( 200 machines ).

The script below appears to work in query analyzer but how do I run it in a dos batch file.

USE ides
EXEC sp_grantlogin 'camisd010a\crmusers'
GO
EXEC sp_grantdbaccess 'crmusers', 'crmusers'
GO
EXEC sp_addrolemember 'db_owner', 'crmusers'


Any help you could be would be greatly appreciated.

Thank you in advance.

Ian Duncan

Sql 7 and Windows 2000 Pro"

dataphile
Yak Posting Veteran

71 Posts

Posted - 2002-06-10 : 03:35:41
You don't.

Connect to each server remotely and run it from Query analyser.

If there is something you are not telling us, use isql :

isql
[-?] |
[-L] |
[
{
{-U login_id [-P password]}
| –E
}
[-S server_name] [-H wksta_name] [-d db_name]
[-l time_out] [-t time_out] [-h headers]
[-s col_separator] [-w column_width] [-a packet_size]
[-e] [-x max_text_size]
[-c cmd_end] [-q "query"] [-Q "query"]
[-n] [-m error_level] [-r {0 | 1}]
[-i input_file] [-o output_file] [-p]
[-b] [-O]
]

Go to Top of Page

efelito
Constraint Violating Yak Guru

478 Posts

Posted - 2002-06-10 : 10:29:20
If you want to execute your T-SQL commands from a batch file you will need to use a tool like isql or osql. There is plenty of info on both of these tools and their switches in BOL.

Jeff Banschbach
Consultant, MCDBA
Go to Top of Page
   

- Advertisement -