尽量不要拼凑Sql语句,用参数来防注入
如果是类似"select * from user where uid="+uid +" and pwd="+pwd 很容易出问题
使用 SQLParamenter
把你的SQL语句写成 类似存储过程
select * from user where uid=@uid and pwd=@pwd
使用这个SQL语句定义为 SQLCommand 对象 然后使用 Paramenter 对象把 @*** 替换为 值
就可以搞定注入式漏洞了
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
sql DATEPART函数使用(摘抄)
sql DATEPART函数使用
DATEPART
返回代表指定日期的指定日期部分的整数。
语法
DATEPART ( datepart ,date )
参数
datepart
是指定应返回的日期部分的参数。下表列出了 Microsoft® SQL Server™ 识别的日期部分和缩写。
日期部分缩写
year
yy, yyyy
quarter
qq, q
mont ......
对日常工作中用到的感觉有用的sql语句做个归纳,用于今后温故知新。
*复制表:
create table tablename as select * from table_src;
create table tablename as select * from table_src where 1 <> 1; --只复制表结构 ......