How to truncate multiple ms sql 2000 tables from ASP in script

Hi,

I would like to know if it is possible to truncate multiple tables from ASP to empty them out?

For example if i truncate in enterprise manager i just type TRUNCATE TABLE tblTestTable but i would like to do this on multiple tables from ASP so in theory something like:

TRUNCATE TABLE tblTestTable, tblTestTable1, tblTestTable2 etc....

Is this possible?

Thanks,
Carl
net-workxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chapmandewCommented:
You can't do it w/ one Truncate, but can wil mulitple w/ no problem.  For example:

TRUNCATE TABLE TABLE1
TRUNCATE TABLE TABLE2
TRUNCATE TABLE TABLE3
TRUNCATE TABLE TABLE4

You can just put all of these calls into one stored procedure, and then call the proceudre to do the work for you.  

CREATE PROCEDURE usp_TruncateTables
AS
TRUNCATE TABLE TABLE1
TRUNCATE TABLE TABLE2
TRUNCATE TABLE TABLE3
TRUNCATE TABLE TABLE4

EXEC usp_TruncateTAbles
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
net-workxAuthor Commented:
Hi sorry for the delay in response....

I have created the store procedure usp_TruncateTables and when i click on it in the stored procedures list in enterprise manager and click on check syntax it returns a confirmation that its all ok...

how do i now run this from ASP?  i have tried to run EXEC usp_TruncateTables in enterprise manager but it returns with procedure has no parameters and arguments were supplied.

Thanks for your help,
Regards,
Carl
0
net-workxAuthor Commented:
Just a bit more info, i have looked into the tables and they seem to have been emptied so im assuming it has run the SP but how do i get it to run from an ASP script?
0
chapmandewCommented:
Take a look at this article.  It shows the different ways to call a sproc from ASP

http://support.microsoft.com/kb/q164485/

0
Anthony PerkinsCommented:
Dim cn
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "Your Connection string goes here"
cn.Execute "YourStoredProcedureNameGoesHere"
cn.Close
Set cn = Nothing

(No points please)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.