Showing posts with label SQL Script. Show all posts
Showing posts with label SQL Script. Show all posts

Wednesday, December 3, 2008

Change the properties of a SQL Server login account

Enabling a disabled login
The following example enables the login Emma.

ALTER LOGIN Emma ENABLE

Changing the password of a login
The following example changes the password of login Emma to 123EEDWQxz829.

ALTER LOGIN Emma WITH PASSWORD = '123EEDWQxz829'


Changing the name of a login
The following example changes the name of login Emma to DavidB.

ALTER LOGIN Emma WITH NAME = DavidB

Tuesday, December 2, 2008

Changing the Name of a Database User

The following piece of T-SQL changes the name of a database user named james to jesse.


Use AdventureWorks;
Alter USER Lara WITH NAME = jesse
GO

Thursday, November 20, 2008

Display Identity Columns in all Tables

This piece of T-SQL displays all the identity columns in all the tables in a Database.

Use Adventureworks
Go
Select o.name, i.name As 'ColumnName'
From sys.identity_columns i, sys.objects o
Where i.object_id = o.object_id
Go