Home > Database > Mysql Tutorial > sql判断表名与字段名是否存在语句

sql判断表名与字段名是否存在语句

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:48:50
Original
1034 people have browsed it

文章介绍了关于sql判断表名与字段名是否存在语句有需要的同学参考一下。

1.字段是否存在

 代码如下 复制代码

if(( count(*) from syscolumns where name = '字段名' and id=(select id from sysobjects where name='表名'))=0)
begin

end

 

2.表是否存在

 代码如下 复制代码

if exists (select * from sysobjects where id = OBJECT_ID('表名') and OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE 表名

Related labels:
Statement of this Website
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
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template