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

SQL查询数据库中每张表的记录数

本文来自:http://hi.baidu.com/darkroot/blog/item/7b74be2cf06d76e78b139903.html
declare   @tbName     nvarchar(500)
declare   @ct      int  
declare   @csql   nvarchar(500)  
declare   #tb   cursor   for  SELECT OBJECT_NAME (id) As TableName from sysobjects WHERE xtype = 'U' AND OBJECTPROPERTY (id, 'IsMSShipped') = 0
open   #tb
fetch   next   from   #tb   into   @tbName
while   @@fetch_status=0
begin 
set @csql = N'Select @ct= Count(*)  from ' + @tbName
Exec dbo.sp_executesql  @csql,N'@ct   int   output',@ct   output
Print @tbName + '---' + Cast(@ct  As  nvarchar(500))
fetch   next   from   #tb   into   @tbName
end    
close   #tb
deallocate   #tb


相关文档:

SQl 语句(常见) 新建,删除,修改表结构

新建表:
create table [表名]
(
[自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] datetime,
[字段4] money null ,
[字段5] int default 0,
[字段6] Decimal (12,4) default 0,
[字段7] image null ,
)
删除表:
Drop table [表 ......

SQl Create Table has error=>is not valid...

今天下了个WIN7的英文包把系统换成英文的。感觉还行,可是当创建数据库表时发现出错了,查了下才知道是SQL的排序出问题了
下面是CTRL+c V搞过来的,只是方便大家有这样的问题可以得到解决
使用SQL2005进行创建数据库的时候,如果遇到创建失败的情况,如下:
Create 对于 数据库“xxxx”失败。 (Microsoft.SqlS ......

SQL按照日、周、月、年统计数据

如: 表:consume_record 
字段:consume (money类型)  date (datetime类型) 
请问怎么写四条sql语句分别按日,按周,按月,按季统计消费总量. 
如:1月 1200元 
2月 3400元 
3月 2800元 
--按日 
select sum(consume),day([date]) from& ......

SQL Access创建表

一、创建一张空表:
Sql="Create TABLE [表名]"
二、创建一张有字段的表:
Sql="Create TABLE [表名]([字段名1] MEMO NOT NULL, [字段名2] MEMO, [字段名3] COUNTER NOT NULL, [字段名4] DATETIME, [字段名5] TEXT(200), [字段名6] TEXT(200))
字段类型:
2 : "SmallInt", // 整型
3 : "Int", ......

Sql 根据名称剔除重复数据、根据id返回最新的

select *
  from (
        select soft.NETMODEL,
                soft.softname,
                soft.softid ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号