Saturday, February 25, 2012

delete tables

I′m new with SQL. I have a CA product that creates every day 44 tables, aways with the same name (RCXXXXX). But this program don′t delete this tables after generate its. I need to delete this tables automatic whent they became 7 days old. Any one can he
lp?
Thanks,
Lud
Take a look in Books Online about 'cursors'. You can build a cursor against
all the user tables by reading from INFORMATION_SCHEMA.TABLES .
You can then build dynamic sql string and execute it like this from inside
the cursor.
exec('drop table xxx')
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"Lud" <anonymous@.discussions.microsoft.com> wrote in message
news:9F3258D6-2B18-4899-B137-1D4E73C609BD@.microsoft.com...
> Im new with SQL. I have a CA product that creates every day 44 tables,
aways with the same name (RCXXXXX). But this program dont delete this
tables after generate its. I need to delete this tables automatic whent they
became 7 days old. Any one can help?
> Thanks,
> Lud
|||Lud,
The below query would give the creation date of the tables whose name starts
with RC
SELECT crdate
FROM sysobjects
WHERE type='U'
AND [name] LIKE 'RC%'
You can schedule a sql job which will find the old ones (use DATEDIFF) and
drop them.
Dinesh
SQL Server MVP
--
SQL Server FAQ at
http://www.tkdinesh.com
"Lud" <anonymous@.discussions.microsoft.com> wrote in message
news:9F3258D6-2B18-4899-B137-1D4E73C609BD@.microsoft.com...
> Im new with SQL. I have a CA product that creates every day 44 tables,
aways with the same name (RCXXXXX). But this program dont delete this
tables after generate its. I need to delete this tables automatic whent they
became 7 days old. Any one can help?
> Thanks,
> Lud

No comments:

Post a Comment