易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL Server主键自动增长的设置

在SQL Server中,如果把表的主键设为identity类型,数据库就会自动为主键赋值。例如:
create table customers (
id int identity(1,1) primary key not null,
name varchar(15)
);
insert into customers(name) values("name1"),("name2");
select id from customers;

查询结果为:
id
---
1
2
由此可见,一旦把id设为identity类型,MS SQLServer数据库会自动按递增的方式为主键赋值。identity包含两个参数,第一个参数表示起始值,第二个参数表示增量。


相关文档:

如何在MS SQL Profiler里面过滤内嵌的存储过程

最近在搞性能优化,由于项目的需要,我们必须尽可能的减少数据库的调用,于是我们做了不少的优化,比如原先需要3个数据库调用的,现在我们把它整合到一个存储过程中,这样只需要一个方法即可。
但这也产生了另外一个问题,之前我们是使用MS SQL Profiler去跟踪数据库的调用的,由于整合了不少存储过程,比如原先需要三个存 ......

SQL递归查询数据

Tree表如下:  
    NodeId   ParentId     NodeName  
    0           -1              &nb ......

SQL 知识

--------------------------------查询系统库中是否有库(有库就删除此库)----------------------------------------------------
use master
if exists(select * from databases where name='库名')
drop database 库名
__________________________  建数据库建表的基本格式  __________________ ......

SQL 版本和补丁

I'm continually trying to track down what service packs are installed on various SQL Servers I support. I can never find the right support page on Microsoft's site. So here's an article with all the SQL Server version information I can track down. If you know of any older versions or can help me fil ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号