Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
h2sut
Starting Member
40 Posts |
Posted - 2007-12-22 : 09:00:32
|
| Say i had a system table in that table i had dbo.user then format (dd,mm,yyyy) after that i had dbo.user_backup_ 10_12_2007,dbo.user_backup_ 10_13_2007,dbo.user_backup_ 10_14_2007,dbo.user_backup_ 10_15_2007,dbo.user_backup_ 10_16_2007If i use the SQL command SELECT * FROM paychexdb.dbo.sysobjects WHERE name like 'users_backup_%' AND xtype = 'U'AND name not in( SELECT Top 3 name FROM paychexdb.dbo.sysobjects WHERE name like 'users_backup_%' AND xtype = 'U'ORDER BY Name DESC)results would be 10_12_2007,10_13_2007.So i want to put those results in a backup file and keep top 3 which is 10_14,10_15,10_16. I want to create a store procedure that i can execute and do that for all my tables. this stored proc (sp) should first backup the table if it doesn't exist and then delete all but the most recent 3 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-12-22 : 10:51:54
|
ORDER BY PARSENAME(REPLACE(Name, '_', '.'), 1) DESC,PARSENAME(REPLACE(Name, '_', '.'), 2) DESC,PARSENAME(REPLACE(Name, '_', '.'), 3) DESC E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|