Ask a Question related to ASP Database, Design and Development.
-
Chopper #1
SQL Replace
I've looked at BOL and through dejanews for a solution (similar post from
Lamine Darbouche on 30th July in this group) but cannot find a solution.
I am trying to replace text within a field using the SP below.
Alter Procedure cc_globalBodyReplace
(
@toReplace varchar(255),
@replaceWith varchar(255),
@result integer OUTPUT
)
AS
SET nocount on
BEGIN
-- Replace body
UPDATE PAGE_ATTRIBUTE
SET BODY = replace(BODY,@toReplace,@replaceWith)
WHERE BODY like '%'+@toReplace+'%'
END
--Return success/fail depending on sql feedback
IF @@Error = 0
select @result = 1
ELSE
select @result = 0
I am getting the following error when trying to save it:
'Argument data type text is invalid for argument 1 of replace function'
From BOL is suggests all arguments are strings but I've seen mention of it
being possible to use a column as the first argument.
I'm using SQL2K SP3a and Visual Studio 6.0 (SP5) as the editor.
The [BODY] column type is text.
TIA
chopper
Chopper Guest
-
Replace XML
I want to replace two parameters on the same replace, the idea it's print in a textArea a XML file from a webService, went i get the XML, but this... -
help with the replace(pattern, replace)
hii i hope you can help me, i want to replace two parameters on the same replace, the idea it's print in a textArea a XML file from a webService,... -
Replace into..??
Hallo Group, is there an equivelant/replacement of the MySQL Command "Replace Into" for Access/MS SQLServer? "Replace Into" does either... -
Search and replace (super global replace)
I am using the 30 day trail of acrobate professional....before I buy it I have a few questions.... 1) is there a "search and replace" function... -
Replace in ASP/VBS/SQL
I need to replace all occurancies of "is" in "This is a test (is), is, penis." with "<a href=is.htm>is</a>". The thing is, if I use a simple... -
Bob Lehmann #2
Re: SQL Replace
The error is just what it says it is. You need to change the type from text
to varchar. If that's not possible, then you can't use the replace function
in your SP.
Bob Lehmann
"Chopper" <chopper@despammed.com> wrote in message
news:3f9e86bd$0$252$cc9e4d1f@news.dial.pipex.com.. .> I've looked at BOL and through dejanews for a solution (similar post from
> Lamine Darbouche on 30th July in this group) but cannot find a solution.
> I am trying to replace text within a field using the SP below.
>
> Alter Procedure cc_globalBodyReplace
> (
> @toReplace varchar(255),
> @replaceWith varchar(255),
> @result integer OUTPUT
> )
> AS
> SET nocount on
> BEGIN
> -- Replace body
> UPDATE PAGE_ATTRIBUTE
> SET BODY = replace(BODY,@toReplace,@replaceWith)
> WHERE BODY like '%'+@toReplace+'%'
> END
> --Return success/fail depending on sql feedback
> IF @@Error = 0
> select @result = 1
> ELSE
> select @result = 0
>
> I am getting the following error when trying to save it:
> 'Argument data type text is invalid for argument 1 of replace function'
> From BOL is suggests all arguments are strings but I've seen mention of it
> being possible to use a column as the first argument.
> I'm using SQL2K SP3a and Visual Studio 6.0 (SP5) as the editor.
> The [BODY] column type is text.
>
> TIA
>
> chopper
>
>
Bob Lehmann Guest
-
Aaron Bertrand - MVP #3
Re: SQL Replace
REPLACE is not a valid method for TEXT/NTEXT datatypes. See
[url]http://www.aspfaq.com/2445[/url]
"Chopper" <chopper@despammed.com> wrote in message
news:3f9e86bd$0$252$cc9e4d1f@news.dial.pipex.com.. .> I've looked at BOL and through dejanews for a solution (similar post from
> Lamine Darbouche on 30th July in this group) but cannot find a solution.
> I am trying to replace text within a field using the SP below.
>
> Alter Procedure cc_globalBodyReplace
> (
> @toReplace varchar(255),
> @replaceWith varchar(255),
> @result integer OUTPUT
> )
> AS
> SET nocount on
> BEGIN
> -- Replace body
> UPDATE PAGE_ATTRIBUTE
> SET BODY = replace(BODY,@toReplace,@replaceWith)
> WHERE BODY like '%'+@toReplace+'%'
> END
> --Return success/fail depending on sql feedback
> IF @@Error = 0
> select @result = 1
> ELSE
> select @result = 0
>
> I am getting the following error when trying to save it:
> 'Argument data type text is invalid for argument 1 of replace function'
> From BOL is suggests all arguments are strings but I've seen mention of it
> being possible to use a column as the first argument.
> I'm using SQL2K SP3a and Visual Studio 6.0 (SP5) as the editor.
> The [BODY] column type is text.
>
> TIA
>
> chopper
>
>
Aaron Bertrand - MVP Guest
-
Chopper #4
Re: SQL Replace
It's with hesitation I top post but here goes...
Many thanks all.
Will let you know how I get on.
chopper
"Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
news:%23VcjJEXnDHA.2432@TK2MSFTNGP10.phx.gbl...from> REPLACE is not a valid method for TEXT/NTEXT datatypes. See
> [url]http://www.aspfaq.com/2445[/url]
>
>
>
>
>
> "Chopper" <chopper@despammed.com> wrote in message
> news:3f9e86bd$0$252$cc9e4d1f@news.dial.pipex.com.. .> > I've looked at BOL and through dejanews for a solution (similar postit> > Lamine Darbouche on 30th July in this group) but cannot find a solution.
> > I am trying to replace text within a field using the SP below.
> >
> > Alter Procedure cc_globalBodyReplace
> > (
> > @toReplace varchar(255),
> > @replaceWith varchar(255),
> > @result integer OUTPUT
> > )
> > AS
> > SET nocount on
> > BEGIN
> > -- Replace body
> > UPDATE PAGE_ATTRIBUTE
> > SET BODY = replace(BODY,@toReplace,@replaceWith)
> > WHERE BODY like '%'+@toReplace+'%'
> > END
> > --Return success/fail depending on sql feedback
> > IF @@Error = 0
> > select @result = 1
> > ELSE
> > select @result = 0
> >
> > I am getting the following error when trying to save it:
> > 'Argument data type text is invalid for argument 1 of replace function'
> > From BOL is suggests all arguments are strings but I've seen mention of>> > being possible to use a column as the first argument.
> > I'm using SQL2K SP3a and Visual Studio 6.0 (SP5) as the editor.
> > The [BODY] column type is text.
> >
> > TIA
> >
> > chopper
> >
> >
>
Chopper Guest
-
Chopper #5
Re: SQL Replace
Worked a treat!
Thanks again.
chopper
"Chopper" <chopper@despammed.com> wrote in message
news:3f9ead55$0$248$cc9e4d1f@news.dial.pipex.com.. .solution.> It's with hesitation I top post but here goes...
> Many thanks all.
> Will let you know how I get on.
>
> chopper
>
> "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
> news:%23VcjJEXnDHA.2432@TK2MSFTNGP10.phx.gbl...> from> > REPLACE is not a valid method for TEXT/NTEXT datatypes. See
> > [url]http://www.aspfaq.com/2445[/url]
> >
> >
> >
> >
> >
> > "Chopper" <chopper@despammed.com> wrote in message
> > news:3f9e86bd$0$252$cc9e4d1f@news.dial.pipex.com.. .> > > I've looked at BOL and through dejanews for a solution (similar post> > > Lamine Darbouche on 30th July in this group) but cannot find afunction'> > > I am trying to replace text within a field using the SP below.
> > >
> > > Alter Procedure cc_globalBodyReplace
> > > (
> > > @toReplace varchar(255),
> > > @replaceWith varchar(255),
> > > @result integer OUTPUT
> > > )
> > > AS
> > > SET nocount on
> > > BEGIN
> > > -- Replace body
> > > UPDATE PAGE_ATTRIBUTE
> > > SET BODY = replace(BODY,@toReplace,@replaceWith)
> > > WHERE BODY like '%'+@toReplace+'%'
> > > END
> > > --Return success/fail depending on sql feedback
> > > IF @@Error = 0
> > > select @result = 1
> > > ELSE
> > > select @result = 0
> > >
> > > I am getting the following error when trying to save it:
> > > 'Argument data type text is invalid for argument 1 of replaceof> > > From BOL is suggests all arguments are strings but I've seen mention> it>> >> > > being possible to use a column as the first argument.
> > > I'm using SQL2K SP3a and Visual Studio 6.0 (SP5) as the editor.
> > > The [BODY] column type is text.
> > >
> > > TIA
> > >
> > > chopper
> > >
> > >
> >
>
Chopper Guest



Reply With Quote

