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 |
|
Firetubes
Starting Member
2 Posts |
Posted - 2006-02-26 : 07:39:47
|
| Hi, I would like to delete some records in a table older than a specified date using a stored procedure. Can anyone help?Thank you,Cynthia |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-02-26 : 09:18:23
|
| first of all, post what sql statements you have...it is always better to work with something or you may search the sticky post by KristenHTH--------------------keeping it simple... |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-26 : 09:41:11
|
| [code]create procedures some_procedure @somedate datetimeasbegin delete yourtable where somedatecol < @somedateend[/code]----------------------------------'KH'It is inevitable |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-27 : 00:50:04
|
| I prefer using where somedatecol < DateAdd(day,DateDiff(day,0,@somedate),0)MadhivananFailing to plan is Planning to fail |
 |
|
|
Firetubes
Starting Member
2 Posts |
Posted - 2006-02-27 : 18:17:31
|
| Thank you for the help! My first stored procedure works. I didn't use the date column but I think I'm on the right track.If my somedatecol is actually a text string with the format 'yy/mm/dd hh:mm:ss', how can I convert this over to check for the date?Regards,Cynthia |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-02-27 : 20:04:56
|
| You should use proper data type. if your somedatecol is a char or varchar, change it to datetime or smalldatetime.You can use convert() to convert from string to datetime.----------------------------------'KH' |
 |
|
|
|
|
|
|
|