SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Delete Query


Delete Query

Author
Message
JakDBA
JakDBA
SSC-Enthusiastic
SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)SSC-Enthusiastic (148 reputation)

Group: General Forum Members
Points: 148 Visits: 401
Hi friends need Delete Query

Delete from StoreGroupMember Where d in (select * from StoreGroupMember a ,store where a.Store_id=Store.id and store.StoreNumber=9833) d
Go

I need to Delete the Records which Satisfies the Below condition,

select * from Table1 a ,Table2 where a.Store_id=Tables2.id and Table2.StoreNumber='AAAA'

And i need to delete the records from Table 1 only,

EG;

Delete from Table1 Where d in (select * from Table1 a ,Table2 where a.Store_id=Tables2.id and Table2.StoreNumber='AAAA') d
Go

Please help me out...

URGENT

@JayMunnangi
Evil Kraig F
Evil Kraig F
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10993 Visits: 7660
The more urgently you need something, the more time you'll need to take writing out the sample code you'd like us to mess with. A couple of things though:

That select * statement? It won't help us figure out what the key/keys are in Table1 to uniquely identify each delete.

General syntax though to delete:

DELETE t1
FROM
Table1 AS t1
JOIN
Table2 AS t2
ON t1.id = t2.id
WHERE
t2.colB = @parameter




- Craig Farrell

Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

For better assistance in answering your questions | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
Derrick Smith
Derrick Smith
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1140 Visits: 715
This should work, I think..:

DELETE D FROM Table1 AS D
INNER JOIN StoreGroupMember A
ON A.Store_ID = D.Store_ID
WHERE A.StoreNumber = 9833



I think I got the tables right, but it's a bit unclear. Are the StoreNumber and Store_ID fields both in the StoreGroupMember table? And you want to delete by StoreNumber?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search