Home  >  Article  >  Database  >  SQL:判断某些元素是否存在及创建的SQL语句

SQL:判断某些元素是否存在及创建的SQL语句

WBOY
WBOYOriginal
2016-06-07 17:38:461503browse

SQL:判断某些元素是否存在及创建的SQL语句 --判断某个存储过程是否存在 [p_CreateTable] --tUser(cid nvarchar(50),name nvarchar(50),age (tableA(id NVARCHAR(50),name NVARCHAR(50)) [tableA] --判断存储过程p_CreateTable是否存在 --(cid nvarchar(50),n

SQL:判断某些元素是否存在及创建的SQL语句


--判断某个存储过程是否存在
[p_CreateTable]
--tUser(cid nvarchar(50),name nvarchar(50),age (tableA(id NVARCHAR(50),name NVARCHAR(50))
[tableA]

--判断存储过程p_CreateTable是否存在
--(cid nvarchar(50),name nvarchar(50),age [p_CreateTable]

--判断视图v_tableAB是否存在
--(

--判断表tableA中的列column1是否存在
--(column1

--判断表tableA是否存在索引Index1
(Index1 on tableA --删除索引

select *from sys.indexes where name = 'Index1'--查看索引




--创建临时表(仅缓存在执行SQL的时候)
DECLARE @tableA TABLE(id NVARCHAR(50),NAME NVARCHAR(50))
INSERT INTO @tableA(id,name)VALUES ('aaa','bbb')
SELECT * FROM @tableA


posted on

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn