March 20, 2013 at 1:00 pm
Hello all,
I need to delete a record that is duplicate between 2 tables.
The query looks like this:
Delete from request_form_table_testing as t1
where EXISTS
(select tEmail from request_form_temp_emails as t2
where t1.email = t2.tEmail)
but is giving me an error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'as'.
I dont really know where is my syntax error.
Could you guys help me?
Thanks a lot
March 20, 2013 at 1:13 pm
montse 22199 (3/20/2013)
Hello all,I need to delete a record that is duplicate between 2 tables.
The query looks like this:
Delete from request_form_table_testing as t1
where EXISTS
(select tEmail from request_form_temp_emails as t2
where t1.email = t2.tEmail)
but is giving me an error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'as'.
I dont really know where is my syntax error.
Could you guys help me?
Thanks a lot
You can't alias the table in your delete statement. You can do the same thing a number of different ways. Here are a couple of them.
Delete request_form_table_testing
where tEmail in
(
select tEmail
from request_form_temp_emails as t2
join request_form_table_testing t1 on t1.email = t2.tEmail
)
delete request_form_table_testing
from request_form_table_testing as t1
where EXISTS
(select tEmail from request_form_temp_emails as t2
where t1.email = t2.tEmail)
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply