SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 delete uning inner join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

yaditzal
Starting Member

22 Posts

Posted - 04/19/2010 :  12:35:07  Show Profile  Reply with Quote
I need to convert this select in a delete.

SELECT FROM [HEDIS_DATA].[dbo].[VISIT_IN] P1

INNER JOIN (SELECT * FROM [HEDIS_DATA].[dbo].[VISIT_IN]
) Pl1
ON Pl1.[CLAIM_ID]= SUBSTRING(P1.CLAIM_ID,CHARINDEX('R',P1.CLAIM_ID)+1,LEN(P1.CLAIM_ID))

WHERE LEFT(P1.[CLAIM_ID],1)='R'

please any help

webfred
Flowing Fount of Yak Knowledge

Germany
8760 Posts

Posted - 04/19/2010 :  12:38:15  Show Profile  Visit webfred's Homepage  Reply with Quote
Be sure to have a backup and then try this:

DELETE P1
FROM [HEDIS_DATA].[dbo].[VISIT_IN] P1
INNER JOIN (SELECT * FROM [HEDIS_DATA].[dbo].[VISIT_IN] ) Pl1
ON Pl1.[CLAIM_ID]= SUBSTRING(P1.CLAIM_ID,CHARINDEX('R',P1.CLAIM_ID)+1,LEN(P1.CLAIM_ID))
WHERE LEFT(P1.[CLAIM_ID],1)='R'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 04/20/2010 :  01:04:27  Show Profile  Reply with Quote
actually there's no need for derived table after inner join as you're anyways selecting all the columns from it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8760 Posts

Posted - 04/20/2010 :  15:24:53  Show Profile  Visit webfred's Homepage  Reply with Quote
Yes, you're right - eagleeye
DELETE P1
FROM [HEDIS_DATA].[dbo].[VISIT_IN] P1
INNER JOIN [HEDIS_DATA].[dbo].[VISIT_IN] Pl1
ON Pl1.[CLAIM_ID]= SUBSTRING(P1.CLAIM_ID,CHARINDEX('R',P1.CLAIM_ID)+1,LEN(P1.CLAIM_ID))
WHERE LEFT(P1.[CLAIM_ID],1)='R'



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 04/21/2010 :  01:43:34  Show Profile  Reply with Quote
cool

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000