收藏几段SQL Server语句和存储过程

2016-01-29 15:53 4 1 收藏

收藏几段SQL Server语句和存储过程,收藏几段SQL Server语句和存储过程

【 tulaoshi.com - SQLServer 】

-- ======================================================

--列出SQL SERVER 所有表,字段名,主键,类型,长度,小数位数等信息

--在查询分析器里运行即可,可以生成一个表,导出到EXCEL中

-- ======================================================

select
       (case when a.colorder=1 then d.name else '' end)表名,
       a.colorder 字段序号,
       a.name 字段名,
       (case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) 标识,
       (case when (select count(*)
       from sysobjects
       where (name in
                 (select name
                from sysindexes
                where (id = a.id) and (indid in
                          (select indid
                         from sysindexkeys
                         where (id = a.id) and (colid in
                                   (select colid
                                  from syscolumns
                                  where (id = a.id)

来源:http://www.tulaoshi.com/n/20160129/1496716.html

延伸阅读
标签: SQLServer
/*备份数据库的过程*/ if exists(  select * from sysobjects   where name=’pr_backup_db’ and xtype=’p’           ) begin  drop proc pr_backup_db end go create proc pr_backup_db @flag&n...
--有输入参数的存储过程--create proc GetComment(@commentid int)asselect * from Comment where CommentID=@commentid --有输入与输出参数的存储过程--create proc GetCommentCount@newsid int,@count int outputasselect @count=count(*) from Comment where NewsID=@newsid --返回单个值的函数--create function MyFunction(@newsid int)...
标签: ASP
  建立表: CREATE TABLE [TestTable] ( [ID] [int] IDENTITY (1, 1) NOT NULL , [FirstName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , [LastName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , [Country] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [Note] [nvarchar] (2000) COLLATE Chinese_PRC_CI_...
标签: SQLServer
  存储过程、存储函数的加密:WITH ENCRYPTION <!--[if !supportLineBreakNewLine]-- <!--[endif]-- CREATE procedure dbo.sp_XML_main @table_name nvarchar(260)='', @dirname nvarchar(20)='' WITH ENCRYPTION as begin .................................................... end go     存储过程、存...
标签: Web开发
1.新建表: CREATE TABLE [mytest] (     [id] [int] NOT NULL ,     [name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,     [phone] [varchar] (13) COLLATE Chinese_PRC_CI_AS NULL ,     [addr] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ) ON [PRIMARY] G...