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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 delete uning inner join

Author  Topic 

yaditzal
Starting Member

22 Posts

Posted - 2010-04-19 : 12:35:07
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
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-19 : 12:38:15
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

52326 Posts

Posted - 2010-04-20 : 01:04:27
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
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-20 : 15:24:53
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

52326 Posts

Posted - 2010-04-21 : 01:43:34
cool

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

Go to Top of Page
   

- Advertisement -