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 2008 Forums
 Transact-SQL (2008)
 Login change

Author  Topic 

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-08-18 : 04:40:50
Hi,

i have written script file for creating database and user login and executin that using sqlcmd. but when i create database and user i use admin account, once the user created, i want to connect using login that i have created in same session. can one help in this
summery: switching from admin to another user and execute some sql command
regard

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2011-08-18 : 16:56:48
One way is to use execute as (from books online)

Be One with the Optimizer
TG
Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-08-19 : 00:13:54
i used execute as user nad execute as login ,when i execute this in ssms it works but when i use this in script file it dose not. it will give error .could not find stored procedure 'o'

Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2011-08-19 : 10:16:37
ok...that has nothing to do with your original question. Post your "script file" and the code you use to launch it.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -