SQL语名 求救!!!!!

txfa 2003-09-25 11:43:32
SQL语名用引分开但当语名中含引号时就出错
如 update mytable set 内容='this is a 'bad'' where track=1
update mytable set 内容='this is a '' where track=2

错误提示: Line 1: Incorrect syntax near 'bad'.
请教如何将<内容>字段更新?

我的意思是保留文本内容,不要告诉我把 'bad'改成 "bad"
因为文字处理时各种标点符号都有,
就拿这件贴子说吧 ,我们可以打入 ' ,它也可以保存

...全文
51 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
aierong 2003-09-25
  • 打赏
  • 举报
回复


update mytable
set 内容='this is a ''bad'''
where track=1

update mytable
set 内容='this is a '''
where track=2



''==='
sdhdy 2003-09-25
  • 打赏
  • 举报
回复
楼上的答案可以,保存进去以后,就是你要求的格式
如:this is a 'bad'
'this is a '
SQL语句必须那么写!
sdhdy 2003-09-25
  • 打赏
  • 举报
回复
在你的前台编程语言里,用类似replace函数,将'替换为'',前台处理较好!
lvcheng606717 2003-09-25
  • 打赏
  • 举报
回复
还是不太懂你的意思,试试:

update mytable set 内容='this is a ''bad''' where track=1
update mytable set 内容='this is a ''bad' where track=2
txfa 2003-09-25
  • 打赏
  • 举报
回复
我的意思是保留原文本内容
zjcxc 元老 2003-09-25
  • 打赏
  • 举报
回复
sql server中,'是字符串定界符,所以要改为:

update mytable set 内容='this is a ''bad''' where track=1
update mytable set 内容='this is a ''' where track=2
txfa 2003-09-25
  • 打赏
  • 举报
回复
要更新的<内容>字段分别为 < 'this is a 'bad' >
< 'this is a 'bad >
伍子V5 2003-09-25
  • 打赏
  • 举报
回复
SQL SERVER里如果数据里有'号,则用''代替
update mytable set 内容='this is a ''bad''' where track=1
update mytable set 内容='this is a ''' where track=2
txlicenhe 2003-09-25
  • 打赏
  • 举报
回复
update mytable set 内容='this is a ''bad''' where track=1 -- this is a 'bad'
update mytable set 内容='this is a ''' where track=2 -- this is a '
subbee 2003-09-25
  • 打赏
  • 举报
回复
up
brook_huang 2003-09-25
  • 打赏
  • 举报
回复
update mytable set 内容='this is a ''bad''' where track=1
update mytable set 内容='this is a ''''' where track=2
yujohny 2003-09-25
  • 打赏
  • 举报
回复
update mytable set 内容=' this is a ''bad'' ' where track=1
update mytable set 内容=' this is a '' ' where track=2

就是用上面的语句,你试试再说,别靠自己猜想
引号里面还有引号的就用两个单引号代替一个单引号
gmlxf 2003-09-25
  • 打赏
  • 举报
回复
update mytable set 内容='this is a ''bad''' where track=1
update mytable set 内容='this is a ''' where track=2
这样没有错。
txfa 2003-09-25
  • 打赏
  • 举报
回复
如果用:
update mytable set 内容=' this is a ''bad'' ' where track=1
update mytable set 内容=' this is a '' ' where track=2

照上面的做法
保存的结果变成了 <' this is a ''bad'' > 和 <this is a '' >
而不是 < 'this is a 'bad' > 和 < 'this is a '> ?

34,875

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧