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

Sql Server 生成数据字典

use Dbname  
go  
select   
    [表名]=c.Name,  
    [表说明]=isnull(f.[value],''),  
    [列名]=a.Name,  
    [列序號]=a.Column_id,  
    [标识]=case when is_identity=1 then '√' else '' end,  
    [主鍵]=case when exists(select 1 from sys.objects x join sys.indexes y on x.Type=N'PK' and x.Name=y.Name   
                        join sysindexkeys z on z.ID=a.Object_id and z.indid=y.index_id and z.Colid=a.Column_id)  
                    then '√' else '' end,  
    [类型]=b.Name,  
    [字节数]=case when a.[max_length]=-1 and b.Name!='xml' then 'max/2G'   
            when b.Name='xml' then '2^31-1字節/2G' 
            else rtrim(a.[max_length]) end,  
    [长度]=case when ColumnProperty(a.object_id,a.Name,'Precision')=-1 then '2^31-1' 
                else rtrim(ColumnProperty(a.object_id,a.Name,'Precision')) end,  
    [小数]=isnull(ColumnProperty(a.object_id,a.Name,'Scale'),0),  
    [是否为空]=case when a.is_nullable=1 then '√' else '' end,  
    [列说明]=isnull(e.[value],''),  
    [默认值]=isnull(d.text,'')      
from   
    sys.columns a &


相关文档:

sql server日期时间函数

Sql Server中的日期与时间函数
1.  当前系统日期、时间
    select getdate() 
2. dateadd  在向指定日期加上一段时间的基础上,返回新的 datetime 值
   例如:向日期加上2天
   select dateadd(day,2,'2004-10-15')  --返回:2004-10-17 00:00:00.000 ......

sql server 判断表/视图/存储过程是否存在

--如果是实表可以用
if exists (select * from sysobjects where id = object_id(N'[dbo].[表名]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[表名]
--如果是临时表可以用(说明,如果用查找实表方法来打临时表会找不到.发布区别对代.)
if object_id('tempdb..##temp') is not null
   ......

SQL Server 2005 用SQL Server的sa无法登录

使用SQL Server身份验证登录时报错:
无法连接到.\SQLEXPRESS.
Additional information:
用户'sa'登录失败。该用户与可信SQL Server 连接无关联。(microsoft SQL Server,Error:18452))
------------------
下面是映射时报的错:
创建对于用户“sa”失败。(microsoft.sqlServer.express.smo)
Additional ......

SQL语句导入导出

SQL语句导入导出
/******* 导出到excel
EXEC master..xp_cmdshell 'bcp SettleDB.dbo.shanghu out c:\temp1.xls -c -q -S"GNETDATA/GNETDATA" -U"sa" -P""'
/*********** 导入Excel
SELECT *
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\test.xls";User ID=Admin;Password=;Extended propert ......

通过分析SQL语句的执行计划优化SQL(一)

优化器在形成执行计划时需要做的一个重要选择是如何从数据库查询出需要的数据。对于SQL语句存取的任何表中的任何行,可能存在许多存取路径(存取方法),通过它们可以定位和查询出需要的数据。优化器选择其中自认为是最优化的路径。
  在物理层,oracle读取数据,一次读取的最小单位为数据库块(由多个连续的操作系统块组成 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号