Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

i have a string as'
update [inventory] SET groupit=1,Group_ID=19780 where Inv_Id= 00252 #update [inventory] SET groupit=1,Group_ID=19780 where Inv_Id= 00251 #update [inventory] SET Inventory_no= [dbo].[fn_GenerateInvNum_withArticleId](00257,0) , Article_DescID=0 , LocationID=1,DeptID=1,UserID= 1  where Inv_Id= 00257 #update [inventory] SET Inventory_no= [dbo].[fn_GenerateInvNum_withArticleId](00281,0) , Article_DescID=0 , LocationID=1,DeptID=1,UserID= 1  where Inv_Id= 00281 #
'
i want to replace '#' with new line.I want the result as
update [inventory] SET groupit=1,Group_ID=19780 where Inv_Id= 00252

update [inventory] SET groupit=1,Group_ID=19780 where Inv_Id= 00251

update [inventory] SET Inventory_no= [dbo].[fn_GenerateInvNum_withArticleId](00257,0) , Article_DescID=0 , LocationID=1,DeptID=1,UserID= 1  where Inv_Id= 00257

.......
.......
for this i have wriiten query as
select replace(@stringwithHash,'#',CHAR(13) + CHAR(10))


but i am geting error as
The name update [inventory] SET groupit=1,Group_ID=19780 where Inv_Id= 00252
update [inventory] SET groupit=1,Group_ID=19780 where Inv_Id= 00251 is not a valid identifier
'

The lengh of
@stringwithHash
has max data.
Posted
Updated 30-Oct-13 1:03am
v2

1 solution

please see this Replace[^]

Varchar max and nvarchar of max is allowed here
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900