I need to replace the tag {URL}:
DECLARE @PageUrl varchar(200)
DECLARE @Body varchar(MAX)
SET @PageUrl = 'http://www.website.com/site1/site2/pageName.asxp?rid=1232'
SET @Body = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus,
{URL} enim nec posuere volutpat, neque dui volutpat turpis. '
SET @Body = REPLACE(@Body,'{Url}', CONVERT(varchar,@PageUrl))
PRINT @Body
My expected result is:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus,
http://www.website.com/site1/site2/pageName.asxp?rid=1232 enim nec posuere volutpat, neque dui volutpat turpis.
And the print result is:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus,
http://www.website.com/site1/s enim nec posuere volutpat, neque dui volutpat turpis.
As you can see the replace function cuts the url string at its 31…
What I’m doing wrong?
The problem is not the
replacemethod , it is theconvertmethod..You need to either specify the length of the converted type
or since it is already defined as a varchar just use the variable..
If you have a look at the char/vachrar page