SQL语句
1. 说明:复制表(只复制结构,源表名:a,新表名:b)
SQL: select * into b from a where 1<>1;
2. 说明:拷贝表(拷贝数据,源表名:a,目标表名:b)
SQL: insert into b(a, b, c) select d, e, f from b;
3. 说明:显示文章、提交人和最后回复时间
SQL: select a.title, a.username, b.adddate
from table a,(
select max(adddate) adddate
from table where table.title=a.title) b
4. 说明:外连接查询(表名1:a,表名2:b)
SQL: select a.a, a.b, a.c, b.c, b.d, b.f
from a LEFT OUT JOIN b ON a.a = b.c;
5. 说明:日程安排提前五分钟提醒
SQL: select *
from 日程安排
where datediff(’’minute’’, f开始时间, getdate())>5
6. 说明:两张关联表,删除主表中已经在副表中没有的信息
SQL: delete from info
where not exists(
select *
from infobz
where info.infid=infobz.infid );
7. 说明:——
SQL: SELECT A.NUM, A.NAME, B.UPD_DATE, B.PREV_UPD_DATE
from TABLE1,(SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE
from (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND
from TABLE2
&nb
相关文档:
本节主要介绍使用CLR创建标量函数,表值函数和聚合函数。
所谓标量函数指的就是此函数只返回一个值。表值函数返回值是一个表。聚合函数是在select语句中使用的,用来聚合一个结果集,类似于Sum()或是Count()等内置的函数,而且真正的自定义聚合函数目前只能用CLR来实现。
下面的例子使用了SQLServer自带的pubs数据库。
1 ......
----------Dbf 导入 Sql Server表----------
以下均以SQL2000、VFP6及以上的表为例
代码导入:查询分析器中执行如下语句(先选择对应的数据库)
-------------如果接受导入数据的SQL表已存在
--如果接受导入数据的SQL表已经存在
Insert Into 已经存在的SQL表名 Select * from openrowset('MSDASQL','Driver=Micros ......
下载地址: http://download.csdn.net/source/1805903
private string ReArrange(string str)
{
string[] keywords = new string[] {"select","from","where","and","order\\s+by","or","into",
"update","set","delete","haveing" ......
bit:0或1的整型数字
int:从-2^31(-2,147,483,648)到2^31(2,147,483,647)的整型数字
smallint:从-2^15(-32,768)到2^15(32,767)的整型数字
tinyint:从0到255的整型数字
decimal:从-10^38到10^38-1的定精度与有效位数的数字
numeric:decimal的同义词
money:从-2^63(-922,337,203,685,477.580 ......
1,SqlServer存储过程的事务处理
一种比较通用的出错处理的模式大概如下:
Create procdure prInsertProducts
(
@intProductId int,
@chvProductName varchar(30),
@intProductCount int
)
AS
Declare @intErrorCode int
Select @intErrorCode=@@Error
Begin transaction
if @intError ......