If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > I can't delete records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-17-03, 05:06
cyu cyu is offline
Registered User
 
Join Date: Nov 2003
Posts: 2
Question I can't delete records

Hi,

My DB is MS SQL Server. I wrote a SQL statement to remove rows from a table as following.

DELETE FROM #TableA
FROM #TableA AS t1
LEFT JOIN #TableA AS t2 ON (t1.Index - 1) = t2.Index
WHERE t2.Index IS NULL

========================================

When I tried to execute it, I got the following error message.
Error Message: The table '#TableA' is ambiguous.

Thanks for your help.
Reply With Quote
  #2 (permalink)  
Old 11-18-03, 07:34
cvandemaele cvandemaele is offline
Registered User
 
Join Date: Oct 2003
Location: Switzerland
Posts: 140
Interesting problem, never thought about it. I can imagine that MSSQL has some problem with guessing what to do.

I know it is not an answer to your question, the following syntax should do the same (if I got the query right) :

DELETE FROM #TableA
WHERE Index-1 NOT IN (SELECT Index FROM #TableA)

ps. Do you really have columns named "Index"
Reply With Quote
  #3 (permalink)  
Old 11-18-03, 20:27
cyu cyu is offline
Registered User
 
Join Date: Nov 2003
Posts: 2
Talking Thanks

You have answered my question.
Many Thanks.

I don't have a column named "Index", it is a alias to simply my question.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On