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

sql语句查询表的字段名

select name from syscolumns where id in (select id from sysobjects where type = 'u' and name = '相应表名')  
用以上sql语句输入相应表名就可以查到表的字段名,对应好数据库 查询是否存在该表语句
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tb_cost]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tb_cost]
GO
创表语句
CREATE TABLE [dbo].[tb_cost] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[inputtime] [datetime] NOT NULL ,
[pushcount] [int] NOT NULL ,
[revertcount] [int] NOT NULL ,
[revertrate] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[unitprice] [float] NOT NULL ,
[cost] [float] NOT NULL ,
[income] [float] NOT NULL ,
[rate] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[pushinfor] [varchar] (8000) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
建索引脚本:
create clustered index 索引名 on 表名(表.字段)
在表增加一个字段,例如fa字段
alter table 表名 add fa int not null default 0
选择前面 m-n 条数据的语句
例如选择前面第 5-10(m=10,n=5) 条记录的sql语句如下:
sql="select top 6 * from table where (id not in (select top 4 id from table order by id desc)) order by id desc"
其中6,4 是这样得来的
sql="select top m-n+1 * from table where (id not  in (select top n-1 id from table))


相关文档:

谈SQL Server 2005中的T SQL增强E


新的关系运算符 PIVOT/UNPIVOT/APPLY
1、PIVOT
PIVOT运算符将行旋转为列,并且可能同时执行聚合。使用PIVOT运算符时要注意的重要一点是,需要为它提供一个查询表达式,表达式使用视图、派生表或者是CTE只返回所关注的列。
2、UNPIVOT
UNPIVOT运算符执行与PIVOT运算符相反的操作;他将列旋转为行了。
3、APPLY ......

sql project dll deploy

To generate a deployment script using generate scripts

Open
Management Studio and connect to the SQL Server instance where the
managed assembly or database object to be deployed is registered.
In the Object Explorer
, expand the <server name>
and Databases
trees. Right-click ......

完全卸载SQL Server 2005

 
1.需要一种下载卸载工具,这里选择微软官方提供的工具(msicuu2.exe)
http://support.microsoft.com/default.aspx?kbid=290301
 
2.使用卸载工具卸载所有SQL Server服务和相关组件(注意:卸载前要先停止对应的服务,否则可能卸载失败)
 
3.删除C:\WINDOWS\inf 下所用文件(我是在该文件夹下搜索&ldquo ......

sql的几个排序函数

1用于排序的函数
row_number()
rank()
dense_rank()
ntile(group_number)
下面列举这个函数的用法:
row_number()函数一般用于组内排序,而其他三个函数是对结果集排序
例子:分页排序
<!--注意全局变量也在这里声明,并用逗号隔开-->
create proc MyDividePageSort @iRowCount int ,@iPageNo int
AS
< ......

SQL关于两表关联的update

关于两表关联的update,但语句怎么写都不正确,老是报错,于是心惊肉跳(就怕不能及时完成操作)去查了一下,NND,原来把SQL写成了在SQL Server下面的特有形式,这种语法在Oracle下面是行不通的,急忙改回来,及时完成了任务。顺便也把查到的SQL帖出来,哪天再忘记了,也好在这里找回来:
   update customers a ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号