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.
| Author |
Topic |
|
-Dman100-
Posting Yak Master
210 Posts |
Posted - 2004-09-13 : 13:21:33
|
| Is there a way I can get the following T-SQL commands to run automatically when restoring a backup? I have created my DB on the testing server with my login account. When I send my hosting the db backup I was curious if there is a way to have these sp's run automatically so the login account is created automatically? I wasn't sure there was a way to do this.Use Mastergo-- Creates a new SQL Server login that allows a user to connect to a server running SQL Server using SQL Server Authentication.EXEC sp_addlogin 'loginAccountName', 'your_choice', 'YourDB'go-- Adds a security account in the current database for a SQL Server login or Microsoft Windows NT user or group, and enables it to be granted permissions to perform activities in the database.EXEC sp_grantdbaccess 'loginAccountName', 'loginAccountName'goUse YourDBGoAdds a security account as a member of an existing SQL Server database role in the current database.EXEC sp_addrolemember 'db_owner', 'loginAccountName'GoThanks.-D- |
|
|
n/a
deleted
35 Posts |
Posted - 2004-09-13 : 14:20:55
|
| The only way I can think to do this, and I have not tested this at all, would be to create an alart on the some database measure (like restore throughput per second) and have it execute a saved job (with your SQL Code in it) when the troughput gets above 0. You would need to test the ALOT before implementing it, but it could be a start.HTHPaul |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-13 : 14:55:38
|
| Schedule a task which check for the Account Name, and if it is missing creates it?No better idea, sorry!Kristen |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-09-13 : 22:21:06
|
| if you're performing the restore using tsql, you can set up a job and include the adding of account as one of the steps after backup,if not...you can create a batch file packaged with the backup file. you can set a trigger to run the file.just a thought... |
 |
|
|
|
|
|
|
|