sql中的#号代表什么呀,请问大家。

爱若一生 2012-09-26 09:47:25
sql.text := ' select * from iccard_tb where (stop_ok_flag is null or stop_ok_flag <> 1) and convert(char(10),card_stop_time,120) <='#39
+ formatdatetime('yyyy-mm-dd', now) + #39 + ' and ICcard_num = '#39 + iccard_num + #39 +
' and ICcard_address_num = '#39 + iccard_address + #39;
...全文
1129 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
-Tracy-McGrady- 2012-09-27
  • 打赏
  • 举报
回复
你这个恐怕是Delphi里面的问题,#39是Delphi里的单引号,数据库里面的#是临时的意思,比如create table #tableName(column int) 就是创建一个临时表。
LQH1029 2012-09-27
  • 打赏
  • 举报
回复
单引号
luck8000 2012-09-27
  • 打赏
  • 举报
回复
单引号

黄_瓜 2012-09-26
  • 打赏
  • 举报
回复
#39 是delphi里的东西就是相当于一个单引号

#39在很少见这种写法,比较好的方式是使用QuotedStr函数,这样写比较易于理解。
常见的写法,也有通过转义字符的。

例1:and convert(char(10),card_stop_time,120) <='QuotedStr(formatdatetime('yyyy-mm-dd', now))+ '
例2:and convert(char(10),card_stop_time,120) <='''+formatdatetime('yyyy-mm-dd', now)+'''
以学习为目的 2012-09-26
  • 打赏
  • 举报
回复
mssql里面#代表局部临时表,你这个#不清楚是什么意思
DBA_磊仔 2012-09-26
  • 打赏
  • 举报
回复

你这个不是SQL里面的#,你没发现他写在SQL语句外面么?这是你编程语言delphi中的单引号,实际应用中很少用这种写法,都是直接用两个单引号实现转义
例如你这个可以写成
sql.text := ' select * from iccard_tb where (stop_ok_flag is null or stop_ok_flag <> 1) and convert(char(10),card_stop_time,120) <='''
+ formatdatetime('yyyy-mm-dd', now) + ''' and ICcard_num = ''' + iccard_num +
''' and ICcard_address_num = ''' + iccard_address + '''';
發糞塗牆 2012-09-26
  • 打赏
  • 举报
回复
SQLServer的#代表局部临时表,不过你这个貌似不像,像是变量多一点。

34,836

社区成员

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

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