如何用sql 2005中的新行替换某些字符 [英] how to replace some character with a new line in sql 2005

查看:66
本文介绍了如何用sql 2005中的新行替换某些字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i有一个字符串为'

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想用新行替换'#'。我希望结果为

'
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



.......

。 ......

这个我有wriiten查询


.......
.......
for this i have wriiten query as

select replace(@stringwithHash,'#',CHAR(13) + CHAR(10))





但我发现错误为

名称更新[库存] SET groupit = 1,Group_ID = 19780其中Inv_Id = 00252

update [inventory] ​​SET groupit = 1,Group_ID = 19780其中Inv_Id = 00251不是有效标识符

'





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

的长度有最大数据。

推荐答案

请参阅此替换 [ ^ ]



这里允许最大的varchar和nvarchar
please see this Replace[^]

Varchar max and nvarchar of max is allowed here


这篇关于如何用sql 2005中的新行替换某些字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆