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 |
|
yumyum113
Starting Member
31 Posts |
Posted - 2007-04-05 : 20:29:59
|
Hi,Not sure if this is possible in a delete query that is why I'm posting out of curiosity.I have a table with one column (int datatype)WorkItem112131----(6 rows)Can I delete the first record whose workitemid is 1So that after the delete the resulting dataset in WorkItemID12131----(5 rows)Thanks,yumyum113  |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-05 : 21:57:35
|
[code]set rowcount 1delete table where workitemid = 1set rowcount 0[/code] KH |
 |
|
|
yumyum113
Starting Member
31 Posts |
Posted - 2007-04-05 : 22:05:13
|
Thanks for the reply. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-05 : 23:33:42
|
Make sure that you reset rowcount to 0 at the end as Tan specified. Otherwise you will end up with unexpected results MadhivananFailing to plan is Planning to fail |
 |
|
|
yumyum113
Starting Member
31 Posts |
Posted - 2007-04-06 : 05:38:35
|
Thank you Guys for your help... I really must say this forum rocks!!! |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-06 : 06:32:37
|
| SQL Server 2005 can use the syntaxDELETE TOP 1FROM Table1WHERE ID = 1Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-06 : 06:48:00
|
quote: Originally posted by Peso SQL Server 2005 can use the syntaxDELETE TOP 1FROM Table1WHERE ID = 1Peter LarssonHelsingborg, Sweden
Thats coolIs Order by also possible?MadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-06 : 08:24:43
|
| No.Peter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|