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
 Transact-SQL (2000)
 String manipulation

Author  Topic 

KabirPatel
Yak Posting Veteran

54 Posts

Posted - 2008-07-01 : 12:14:07

Hi,

I have a table with the following structure:

componentDisplayName | URL
-----------------------------------------------------
|
|
|

An example of a component would be "Test.doc"
An exmaple of a URL would be the following:

"https://bogus.com/bogus/boguslink.exe?func=ll&objId=80136765&objAction=download"

I need to update the ObjectID's in the URL with one stored in another table. The objectID is the set of numbers after the &objID= part of the URL.

Each URL always has a "&objID=" and "&objAction"

The other table contains data in the following format.

componentDisplayName | ObjectID
-------------------------------------------------------
Test.doc 4567777


I need to write code to update the URL so that in the above example the URL would become:

"https://bogus.com/bogus/boguslink.exe?func=ll&objId=4567777&objAction=download"

I am finding it dificult to extract the ObjectID from the URL. Can somebody help?

Thanks,
Kabir

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-07-01 : 12:34:21
IF the objectid is always length 8, try this:
DECLARE @str varchar(1000)

SET @str = 'https://bogus.com/bogus/boguslink.exe?func=ll&objId=80136765&objAction=download'
SELECT STUFF(@str,PATINDEX('%&objID%',@str)+7,8,'4567777')

Jim
Go to Top of Page
   

- Advertisement -