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 |
rockingdesi
Starting Member
31 Posts |
Posted - 2007-09-11 : 16:14:19
|
Hi,I have a query that is executing properly but i want to delete the results of the query. I am trying to do it but i am messing up somewhere in the syntaxCan anybody help me out with this problem?Below is the queryDELETE FROM DPT_NEW_BINS WHERE(Select BIN,LEFT(ACCT_NUM_MIN,16), LEFT(ACCT_NUM_MAX,16), ISO_CTRY_CD, REGN_CD ,PROD_TYPE_CD FROM DPT_NEW_BINS o WHERE EXISTS (SELECT BIN,LEFT(ACCT_NUM_MIN,16), LEFT(ACCT_NUM_MAX,16), ISO_CTRY_CD, REGN_CD ,PROD_TYPE_CD FROM DPT_temp_NEW_BINS i WHERE o.ACCT_NUM_MIN = i.ACCT_NUM_MIN AND o.ACCT_NUM_MAX = i.ACCT_NUM_MAX))CAN SOMEBODY POINT OUT MY MISTAKE? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-09-11 : 16:17:08
|
Your SELECT statement seems a bit complex for something that I think can be accomplished with a simple join:DELETE oFROM DPT_NEW_BINS o INNER JOIN DPT_temp_NEW_BINS i ON o.ACCT_NUM_MIN = i.ACCT_NUM_MIN AND o.ACCT_NUM_MAX = i.ACCT_NUM_MAXTo make sure that it works before actually running it, run this:SELECT *FROM DPT_NEW_BINS o INNER JOIN DPT_temp_NEW_BINS i ON o.ACCT_NUM_MIN = i.ACCT_NUM_MIN AND o.ACCT_NUM_MAX = i.ACCT_NUM_MAXTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2007-09-11 : 16:18:06
|
have you tried a join as source of your delete criteria?check BOL for the syntax--edit: you're just too fast Tara --------------------keeping it simple... |
|
|
rockingdesi
Starting Member
31 Posts |
Posted - 2007-09-11 : 16:19:30
|
Thanks tara i got it.Thanks for the great help. |
|
|
|
|
|
|
|