如何找到替换sqlserve中的extact匹配单词 [英] how to find replace a extact match word in sqlserve
本文介绍了如何找到替换sqlserve中的extact匹配单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sqlserver中找到替换extact匹配单词
声明 strsql varchar (max)
set strsql = 日期 @ TransactionDate 和 @ TransactionDate2
replace(strsql, @ TransactionDate ,2014-11-27)
例如在这种情况下,如果我想只替换TransactionDate在字符串中有一些值那么它应该只替换TransactionDate但是不是TransactionDate2。
问候,
Rajshree
解决方案
我认为你的正在寻找这个
声明 @ strsql varchar (max)
set @strsql = ' 日期应该在TransactionDate和TransactionDate2之间' / span>
set @ strsql = SPACE( 1 )+ @ strsql + SPACE(< span class =code-digit> 1 )
选择 Rtrim(Ltrim(替换( @ strsql ,SPACE( 1 )+ ' < span class =code-string> TransactionDate' + SPACE( 1 ),SPACE( 1 )+ ' 2014-11-27' + SPACE( 1 跨度>))))
how to find replace a extact match word in sqlserver
declare strsql varchar(max)
set strsql = The Date Should be between @TransactionDate and @TransactionDate2
replace(strsql, @TransactionDate, 2014-11-27)
for example in this case if i want replace only TransactionDate with some value in string then it should be replace only TransactionDate but Not TransactionDate2.
regards,
Rajshree
解决方案
I think your are looking for this
declare @strsql varchar(max) set @strsql = 'The Date Should be between TransactionDate and TransactionDate2' set @strsql=SPACE(1)+@strsql+SPACE(1) select Rtrim(Ltrim(replace(@strsql, SPACE(1)+'TransactionDate'+SPACE(1),SPACE(1)+'2014-11-27'+SPACE(1))))
这篇关于如何找到替换sqlserve中的extact匹配单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文