October 7, 2010 at 7:04 am
Hi I have the following field in a refernece table ...
ARMPMAEWC : ARMPM
I have the following field in another table which i need to link to using the above key
ARMPMAEWC
How do i trim the top field so i loose every thing after the : ??
This way I can then link the two tables
Thanks in advance
October 7, 2010 at 7:07 am
Use the combination of charindex and substring function to get the results you want and then perform the linking
http://msdn.microsoft.com/en-us/library/ms186323.aspx
http://msdn.microsoft.com/en-us/library/ms187748.aspx
---------------------------------------------------------------------------------------
It begins by taking the first step.
October 7, 2010 at 7:22 am
Leju Geevarghese (10/7/2010)
Use the combination of charindex and substring function to get the results you want and then perform the linking
Uh-huh... got some code that might show how to pull off that particular combination including the join? 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
October 7, 2010 at 7:30 am
p.stevens76 (10/7/2010)
Hi I have the following field in a refernece table ...ARMPMAEWC : ARMPM
I have the following field in another table which i need to link to using the above key
ARMPMAEWC
How do i trim the top field so i loose every thing after the : ??
This way I can then link the two tables
Thanks in advance
Here's a way to strip the data as you requested...
DECLARE @SomeString VARCHAR(100)
SELECT @SomeString = 'ARMPMAEWC : ARMPM'
SELECT SUBSTRING(@SomeString, 1, CHARINDEX(' :',@SomeString+' :')-1)
The problem is that you shouldn't leave the data that way because it's in a denormalized condition which is going to continue to cause you grief. If you were to post some data (please see the first link in my signature line below for how to do that properly), one of us could show you how to split these off into columns in a table. If you can't modify the table for some reason, let us know that too because there are some high speed work arounds.
Part of the problem of leaving the table denormalized is that you can't use indexes like they should if you always have to calculate the value from the column.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 11, 2010 at 3:11 am
Many Thanks for your helps. Have sorted the issue now with the original source file.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply