|
 |
asp_components thread: Fw: Creating a Database through code
Message #1 by "Bharat Saboo" <bharatsaboo@h...> on Wed, 27 Mar 2002 18:03:54 +0530
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_001C_01C1D5B9.C2443300
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Subject: Creating a Database through code
hi all !!!!
i am trying to create a database and then a login for this database
through code. tell me how to do it.
i am using sql-server.
please respond immediately as i am stuck up
thnx in advance
bharat
Message #2 by "Geoff Hankerson" <ghank@l...> on Wed, 27 Mar 2002 08:43:43 -0600
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0005_01C1D56B.803CCDD0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
You need to use the Create Tabkle syntax in SQL. Here is an example from
the SQL server online help:
CREATE TABLE employee
(
emp_id empid
CONSTRAINT PK_emp_id PRIMARY KEY NONCLUSTERED
CONSTRAINT CK_emp_id CHECK (emp_id LIKE
'[A-Z][A-Z][A-Z][1-9][0-9][0-9][0-9][0-9][FM]' or
emp_id LIKE '[A-Z]-[A-Z][1-9][0-9][0-9][0-9][0-9][FM]'),
/* Each employee ID consists of three characters that
represent the employee's initials, followed by a five
digit number ranging from 10000 through 99999 and then the
employee's gender (M or F). A (hyphen) - is acceptable
for the middle initial. */
fname varchar(20) NOT NULL,
minit char(1) NULL,
lname varchar(30) NOT NULL,
job_id smallint NOT NULL
DEFAULT 1
/* Entry job_id for new hires. */
REFERENCES jobs(job_id),
job_lvl tinyint
DEFAULT 10,
/* Entry job_lvl for new hires. */
pub_id char(4) NOT NULL
DEFAULT ('9952')
REFERENCES publishers(pub_id),
/* By default, the Parent Company Publisher is the company
to whom each employee reports. */
hire_date datetime NOT NULL
DEFAULT (getdate())
/* By default, the current system date is entered. */
)
----- Original Message -----
From: Bharat Saboo
To: ASP components
Sent: Wednesday, March 27, 2002 6:33 AM
Subject: [asp_components] Fw: Creating a Database through code
Subject: Creating a Database through code
hi all !!!!
i am trying to create a database and then a login for this database
through code. tell me how to do it.
i am using sql-server.
please respond immediately as i am stuck up
thnx in advance
bharat
%%email.unsub%%
Message #3 by "Bharat Saboo" <bharatsaboo@h...> on Wed, 27 Mar 2002 22:46:10 +0530
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_003F_01C1D5E1.3102A7A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
thnx Geoff for replying
but u got it all wrong. i know we can create tables thru code, i want
to create a sql-server database thru code. also i would like to create
a new login to the sql-server with password set.
also how can i change the password for an existing login.
hope the above clears the question
bharat
----- Original Message -----
From: Geoff Hankerson
To: ASP components
Sent: Wednesday, March 27, 2002 8:13 PM
Subject: [asp_components] Re: Fw: Creating a Database through code
You need to use the Create Tabkle syntax in SQL. Here is an example from
the SQL server online help:
CREATE TABLE employee
(
emp_id empid
CONSTRAINT PK_emp_id PRIMARY KEY NONCLUSTERED
CONSTRAINT CK_emp_id CHECK (emp_id LIKE
'[A-Z][A-Z][A-Z][1-9][0-9][0-9][0-9][0-9][FM]' or
emp_id LIKE '[A-Z]-[A-Z][1-9][0-9][0-9][0-9][0-9][FM]'),
/* Each employee ID consists of three characters that
represent the employee's initials, followed by a five
digit number ranging from 10000 through 99999 and then the
employee's gender (M or F). A (hyphen) - is acceptable
for the middle initial. */
fname varchar(20) NOT NULL,
minit char(1) NULL,
lname varchar(30) NOT NULL,
job_id smallint NOT NULL
DEFAULT 1
/* Entry job_id for new hires. */
REFERENCES jobs(job_id),
job_lvl tinyint
DEFAULT 10,
/* Entry job_lvl for new hires. */
pub_id char(4) NOT NULL
DEFAULT ('9952')
REFERENCES publishers(pub_id),
/* By default, the Parent Company Publisher is the company
to whom each employee reports. */
hire_date datetime NOT NULL
DEFAULT (getdate())
/* By default, the current system date is entered. */
)
----- Original Message -----
From: Bharat Saboo
To: ASP components
Sent: Wednesday, March 27, 2002 6:33 AM
Subject: [asp_components] Fw: Creating a Database through code
Subject: Creating a Database through code
hi all !!!!
i am trying to create a database and then a login for this database
through code. tell me how to do it.
i am using sql-server.
please respond immediately as i am stuck up
thnx in advance
bharat
To unsubscribe send a blank email to %%email.unsub%%
bharatsaboo@h...
%%email.unsub%%
Message #4 by "John Wm. Wicks" <j_wicks@p...> on Sat, 30 Mar 2002 10:07:07 -0800
|
|
Bharat Saboo wrote:
>----------------------------------------------------------------------
>
>Subject: Fw: Creating a Database through code
>From: "Bharat Saboo" <bharatsaboo@h...>
>Date: Wed, 27 Mar 2002 18:03:54 +0530
>Subject: Creating a Database through code
>
>
>hi all !!!!
>
>i am trying to create a database and then a login for this database
>through code. tell me how to do it.
>
>i am using sql-server.
>
>please respond immediately as i am stuck up
>
>thnx in advance
>
>bharat
>
Hello Bharat,
Check out CREATE DATABASE. You have to be a member of the sysadmin or
dbcreator roles to use CREATE DATABASE or have been granted permission
by a GRANT statement.
As for the user there are several ways, you can use the CREATE USER and
GRANT SQL statements or depending on whether your using a NT login or
creating a SQL login you can use sp_grantlogin or sp_addlogin and
sp_grantdbaccess.
John
|
|
 |