|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Need some help with DELETE command
Hello,
I am new to SQL and am learning basics in a class. I am having a problem with deleting. I have this table that looks like (only a small portion shown): letter lDate a 1/1/98 a 1/1/98 a 1/1/98 a 1/1/99 a 1/1/99 b 1/1/99 c 1/1/97 d 1/1/99 I want to delete all letter a with dates before 1/1/99. Could someone please help me out?...I can't seem to get this to work. Thank you, Tazz |
|
#2
|
|||
|
|||
|
Here's how to code a DELETE
Code:
Delete from [myTable] where [filter criteria] ...not to hard, but be careful. B/c they can be somewhat disasterous, I'd advise pre SELECTing what you want to delete first, just to be sure you're whacking the correct data. Just do a normal query to get what you're looking for then just change the Select * to Delete. Honestly, test this code, I'm not familiar w/dates in that format, @some pont these should select the records you're looking for ...Code:
--1) select * from myTable where letter = 'A' and lDate < '1/1/99' --or 2) since you want everything before Jan 1st, 1999 select * from myTable where letter = 'A' and YEAR(lDate) < '99' --may need to use '1999' ...then simply Delete 'em. Last edited by Username=NULL : May 11th, 2004 at 12:02 AM. |
|
#3
|
|||
|
|||
|
Thank you very much, It worked with the 1999.
Thankz again, Tazz |
|
#4
|
|||
|
|||
|
sure Tazz, anytime.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Need some help with DELETE command |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|