SQL Server中授予用户查看对象定义的权限 在SQL Server中,有时候需要给一些登录名(用户)授予查看所有或部分对象(存储过程.函数.视图.表)的定义权限存.如果是部分存储过程.函数.视图授予查看定义的权限,那么就像下面脚本所示,比较繁琐: GRANT VIEW DEFINITION ON YOUR_PROCEDURE TO USERNAME; GRANT VIEW DEFINITION ON YOUR_FUNCTION TO USERNAME; GRANT VIEW D…
--SQL Server中 数表: SELECT * FROM SYSOBJECTS WHERE xtype = 'U'; SELECT COUNT(*) FROM SYSOBJECTS WHERE xtype = 'U'; --数视图: SELECT * FROM SYSOBJECTS WHERE xtype = 'V'; SELECT COUNT(*) FROM SYSOBJECTS WHERE xtype = 'V'; --数存储过程 SELECT * FROM SYSOBJECTS WH…
1 判断数据库是否存在Sql代码 if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名] if exists (select * from sys.databases where name = ’数据库名’) drop database [数据库名]2 判断表是否存在Sql代码 if exists (select * from sysobjects where id = objec…
一.注释中带某关键字的对象 主要用到 sys.tables .sys.columns .sys.procedures 系统对象表以及sys.extended_properties 扩展属性表 --查询列 SELECT A.name AS table_name , B.name AS column_name , C.value AS column_description FROM sys.tables A INNER JOIN sys.columns B ON B.object_id = A.o…
转自:http://www.jb51.net/article/56691.htm IF OBJECT_ID('DBO.DISTINCT_STR') IS NOT NULL DROP FUNCTION DBO.DISTINCT_STR GO --此函数操作形如["a", "b", 1,2,3,1,"a"]的数组,去重后,["b",1,2,3] --@S(原有参数), @SPLIT(分隔符), @NEW_STR(新添加字符串) )…