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
 General SQL Server Forums
 New to SQL Server Programming
 help!!!!built in function in sql

Author  Topic 

smithani
Starting Member

42 Posts

Posted - 2007-08-15 : 16:34:32
Hi,
Is there some kind of built in function in SQl to look for the presence of certain characters in a table collumn.I have to replace the text in those collumns with different text or just use substr, instr functions.
Thanks in advance

nathans
Aged Yak Warrior

938 Posts

Posted - 2007-08-15 : 16:37:43
How about the REPLACE function?


declare @string varchar(20)
set @string = 'shrek.avi'

select @string 'pre'

set @string = replace(@string, '.avi', '.mpg')

select @string 'post'

Nathan Skerl
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2007-08-15 : 16:38:40
There is a REPLACE function.

Jim
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-15 : 17:01:39
look for charindex and patindex

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

smithani
Starting Member

42 Posts

Posted - 2007-08-16 : 09:43:29
Thanks all of you, I used the charindex, subscript and replace functions to do my thing.
Here is how it looks

DECLARE @dt VARCHAR(100), @delim1 CHAR(1),@delim2 CHAR(1),@var char(1)
set @dt='what do you think of this {this is good , but not always} is always good'
set @delim1='{';
set @delim2='}'

select Replace( @dt,SUBSTRING(@dt,CHARINDEX(@delim1, @dt), CHARINDEX(@delim2, @dt)+1-CHARINDEX(@delim1, @dt)),'')
Go to Top of Page
   

- Advertisement -