Groups | Blog | Home
all groups > sql server mseq > july 2004 >

sql server mseq : SQL DB


William
7/5/2004 6:19:56 AM
G'Day folks,

My question is related to deleting an existing db in sql.

The reason why I need to delete the existing db in sql is
to update the db from my log file.

Example for the table jobs, I need to delete all JobId's
from the db.

Can anyone tell me the function that will allow me to
delete my current db?

William
7/5/2004 7:14:30 AM
Hello,

What I want to do is delete all data found in jobs table
because I need to update it by running a script on a log
file.

When i wrote your function it gave me a script error in
[quoted text, click to view]

FROM Jobs alter_database < Jobs >
SET single_user WITH ROLLBACK immediate go
DROP DATABASE < Jobs >

I also looked for the easier way which is by from
Enterprise manager .. Expland databases.. Select
database.. Right click
and Delete, but I can't find Expland databases in
Enterprise Manager.

Can someone tell me where it is and tell why I'm not able
to delete everything from Jobs table?


Cheers!




[quoted text, click to view]
Hari Prasad
7/5/2004 6:45:41 PM
Hi,

Are you trying to delete the data from table or remove the database fully.

Command to remove database. (Can anyone tell me the function that will
allow me to delete my current db?)

alter_database <dbname> set single_user with rollback immediate
go
drop database <dbname

or
from Enterprise manager .. Expland databases.. Select database.. Right click
and Delete


command to delete data from table (I need to delete all JobId's from the
db.)

See

DELETE command in books online.

--
Thanks
Hari
MCDBA

[quoted text, click to view]

Hari Prasad
7/6/2004 8:28:20 AM
Hi,

(FYI, See the responses in programming group.)

It seems you have to delete the jobs table, not the entire database.

1. Login to Query analyzer

2. Select the database in which jobs table reside

3. Execute the below command to clear the table.

TRUNCATE TABLE Jobs

4. The above command will return an error if jobs table have foreign key
relation. in that case use DELETE Command

DELETE from jobs

Note:

Dropping the database will clear all the objects and data inside the
database.

--
Thanks
Hari
MCDBA
[quoted text, click to view]

AddThis Social Bookmark Button