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 2005 Forums
 Transact-SQL (2005)
 script to delete a string

Author  Topic 

jsinks
Starting Member

13 Posts

Posted - 2007-03-20 : 03:41:26
hi;
i want to write a script to delete search for a string in a paragraph, if found it should be deleted.

will appreciate any help

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-20 : 03:50:31
[code]
declare @str nvarchar(4000),
@del nvarchar(100)

select @str = 'hi;
i want to write a script to delete search for a string in a paragraph, if found it should be deleted.
will appreciate any help'

select @del = 'delete'

select @str = replace(@str, @del, '')

print @str
/*
hi;
i want to write a script to search for a string in a paragraph, if found it should be d.
will appreciate any help
*/
[/code]


KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-20 : 04:14:56
This is a forum for posting working queries.
Questions should be asked in proper forum.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-20 : 04:24:29
Oh did not notice that.

Hereafter avoid this


(c) madhi


KH

Go to Top of Page

jsinks
Starting Member

13 Posts

Posted - 2007-03-20 : 05:47:55
hey, thanks Khtan. I am sure this will help, I want to use the script you have just shown me to delete the string 'SQLSTATE 01000' from a stored procedure called Print_test which when executed from sql server argent, its output is "I want to omit [SQLSTATE 01000]"

The expected output should be "I want to omit".

i will inform you if i manage. you can tell me if you have a solution while am trying.

Thanks
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-20 : 08:05:04
[code]
declare @str varchar(100)

select @str = 'I want to omit [SQLSTATE 01000]'

select replace(@str, '[SQLSTATE 01000]', '')
[/code]


KH

Go to Top of Page

jsinks
Starting Member

13 Posts

Posted - 2007-03-21 : 07:17:46
Thank you
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-03-21 : 09:40:25
quote:
Originally posted by Peso

This is a forum for posting working queries.
Questions should be asked in proper forum.


Peter Larsson
Helsingborg, Sweden




Aw come on, he did say the word script



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

jsinks
Starting Member

13 Posts

Posted - 2007-05-07 : 03:19:41
Hi, Khtan.
You solution has been so heplful, i have been using it in many instances. however each time i use replace, i am having lines above the printed output.plz help!!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-07 : 08:42:21
what do you mean " lines above the printed output"


KH

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-07 : 08:46:28
I believe he means column headers...

jsinks,
If you want to turn the column headers (and lines) off, goto Tools, Options, Results and uncheck option "Print Column Headers".

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

jsinks
Starting Member

13 Posts

Posted - 2007-05-10 : 05:18:18
Thank you but the job is in SQL Server Agent not in Query analyser.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-10 : 08:40:38
Topic moved from script library.

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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-10 : 08:48:35
First action as moderator, huh?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-10 : 09:00:35
yup. just getting the hang of it

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-10 : 09:40:08
quote:
Originally posted by spirit1

yup. just getting the hang of it

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp


Keep it up

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -