MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 22nd, 2004, 11:43 AM
MACShug MACShug is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 MACShug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Deleting Records from a MS SQL database

I have a stored procedures that was design to remove all records from a particular table. I am developing this application in a ASP.Net environment. The problem I am having is that the procedure deletes all the records except the first record. Here is the stored procedure:

CREATE PROCEDURE DeletePayrollRec AS

delete from payrolltrans
GO

Thanks in advance for your help

Reply With Quote
  #2  
Old April 22nd, 2004, 05:17 PM
Username=NULL Username=NULL is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: TX
Posts: 249 Username=NULL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 7 h 6 m 42 sec
Reputation Power: 5
Send a message via Yahoo to Username=NULL
This idea might just be a rigged work around, not sure why the 1st record is being left in there. Is there an ID, autonumber, or other numeric field? As long as the field doesn't go into negative values (which usually they don't or shouldn't), just try adding a where clause and it should catch all the records...
Code:
Delete from PayRollTrans
where  ID > 0

...or you can just try to TRUNCATE the table?

Last edited by Username=NULL : April 22nd, 2004 at 05:20 PM.

Reply With Quote
  #3  
Old April 23rd, 2004, 02:04 PM
MACShug MACShug is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 MACShug User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking

THANK YOU!!!

I change the SP to check for a null value in the PK field and it worked.


Thanks again!


Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Deleting Records from a MS SQL database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway