Hi Vikash,
Thanks for your response however its giving me an error that "Instr" is not a recognized function. Anyhow I wrote a query using parse function as below and it works fine.
declare @test table
( regionName varchar(40)
)
insert into @test
select RegionName from [Guidant Field Force Table]
select * from @test
select regionName,
isnull( parsename( replace(regionName,'-','.'),2),
parsename( replace(regionName,'*','.'),2))
as firstPart
from @test
The problem I'm having is that there is another column named "ID" in the table that should be linked to the new "firstpart". So can you suggest any way to link the original column "ID" to this query result?
So basically original "Guidant field force table" is:
ID RegionName
289 SIERRA NEVADA-CRM*CORDERO
482 CARDIAC NW REGION* TREBBE
US20 SOUTH BAY-CRM*HENKHAUS
UF40 INLAND EMPIRE-CRM*LIPKOWSI
And my result should look like:
ID RegionName
289 SIERRA NEVADA
482 CARDIAC NW REGION
US20 SOUTH BAY
UF40 INLAND EMPIRE
So I'm able to achieve the correct result for column "RegionName" using my query but I don't know how to get the associated ID no. as well. Please advise
|