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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding users using sript

Status
Not open for further replies.

cpitc

IS-IT--Management
Dec 20, 2009
77
GB
Hi

I used this example to add a user log in. it worked ok on my SQL epxpress query analyser, but on some colleagues it didnt and would nt allow the script. It appears there can be script for Windows log in and SQL log in. We took the N out and this worked. Could someone please explain what the N is and also explain (perhaps with example using below) on one for window and one for sql log in. Thanks

CREATE LOGIN [cp] WITH PASSWORD=N'leeds',
CHECK_EXPIRATION=ON, CHECK_POLICY=ON,
DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[English];
 
I can tell you that the N'leeds' is converting the character string leads to data type nvarchar. Can't help you with the rest.
 
As for the rest, the following script should work,

USE tableschema;
CREATE CERTIFICATE acertificatename1
WITH SUBJECT = 'username01 certificate in tableschema database',
EXPIRY_DATE = '31-Dec-2010';
GO
create
login username01
with
password somepassword02
must_change,
default_language = english,
default_database = somedatabase,
check_expiration = on,
check_policy = on;
go
 
Hi

I cannot get this script to work. If I ahve a database called

CPMonday and I want to add a user called Colin with password colin01 what would the script look like. I have tired changing it where I logically think it should be looking at your script (as below) but I get variouse error messages. I am ot sure either waht the certificate and subject mean.

USE tableschema;
CREATE CERTIFICATE acertificatename1
WITH SUBJECT = 'username01 certificate in tableschema database',
EXPIRY_DATE = '31-Dec-2010';
GO
create
login 'colin'
with
password 'colin01',
must_change,
default_language = english,
default_database = CPMonday,
check_expiration = on,
check_policy = on;
go


Msg 911, Level 16, State 1, Line 1
Could not locate entry in sysdatabases for database 'tableschema'. No entry found with that name. Make sure that the name is entered correctly.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'colin'.
Msg 319, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.

Thanks
 
Hi

This works fine for SQL log in

-- Code to create a SQL login
CREATE LOGIN [cp] WITH PASSWORD='leeds',
CHECK_EXPIRATION=ON, CHECK_POLICY=ON,
DEFAULT_DATABASE=[cpmonday], DEFAULT_LANGUAGE=[English];

but what can I use for Windows log in credentials

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top