Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can we rename user in sql server 7? urgent?

Status
Not open for further replies.

mkey

Programmer
Joined
Oct 3, 2001
Messages
288
Location
CA
Hi all,
I know using sp_renamedb we can rename a database. Can we rename a user?
Thanks!
 
There is no stored procedure to do this so far as I know. You can update system tables to rename Users in databases and Logins on the database. However, there are consequences. If a User owns objects, you'll need to change the object owner after changing the User Name. If you change the login name Jobs owned by the Login may not be accessible, logins in BAT files, packages, and applications will fail.

1) Rconfigure SQL Server to allow system table updates.

sp_configure 'allow updates', 1
go
reconfigure with override
go

2) to change a user name in a user database.

Update dbname..sysusers
Set name = 'oldname'
Where name='newname'
Go

3) to change the server login name

Update master..sysxlogins
set name='oldname'
Where name='newname'
go

4) reset the option that allows system table ad hoc updates.

sp_configure 'allow updates', 0
go
reconfigure with override
go
Terry L. Broadbent - Salt Lake City, UT
Home of the 2002 Winter Olympics (Feb 8-24)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top