sql语句错误 - MS-SQL Server / 基础类
select * from dbo.[Report] where ID like %1% or Report_num like %1% or ID like %ehs% or Report_num like %ehs% order by ID ;
消息 102,级别 15,状态 1,第 1 行
'1' 附近有语法错误。
select * from dbo.[Report] where ID like '%1% 'or Report_num like '%1% 'or ID like '%ehs% 'or Report_num like' %ehs%' order by ID
like '%1%'
'%1%'
后面的那些条件也都要加上引号
...数据库里的字符串要加引号的呀!
SQL code:
select *
from dbo.[Report]
where ID like '%1% 'or Report_num like '%1%'
or ID like '%ehs%' or Report_num like '%ehs%'
order by ID
SQL code:
select *
from dbo.[Report]
where ID like '%1%' or Report_num like '%1%'
or ID like '%ehs%' or Report_num like '%ehs%'
order by ID
LIKE后面加引号,同时注意引号内不能有空格,除非特殊需要。
加上''
这个单引号我后来自己也找出来了,但现在是我的语句在数据库里可以运行,在C#编译器里就不行了。详细语句见下:
select * from dbo.[Report] where ID like '%1%' or Report_num like '%1%' or ID like '%ehs%' or Report_num like '%ehs%' order by ID ;
在数据库没问题。在vs2005里,代码如下:
C# code
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www
相关问答:
执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例:
......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
我觉得mysql和sqlserver有共同的地方:
有个问题是关于表的锁问题:
进程A 进程B
select * from user where id in lock share mode(共享锁)
&nb ......