The following is a brief description of the SQL query for the existence of a table and returns the ID value of the new data.
1. Whether the query table exists:
table name: "T_demo", type = ' u ' See if it is a user table
SELECT * from sysobjects where id = object_id (' T_demo ') and type = ' u ' select * from sys.tables where name= ' T_demo ' and Typ e = ' u '
2. Whether the query field exists:
Table name: "t_demo", Field name "Demoid"
SELECT * from syscolumns where name= ' demoid ' and objectproperty (ID, ' isusertable ') =1 andobject_name (id) = ' t_demo '
3. Returns the maximum value of a self-increment field that can be used to return the ID value of the data just added.
Field name: Ndsid table name: tb_nds
Select Max (NDSID) from Tb_nds
This article is from the "World is the same" blog, please be sure to keep this source http://970076933.blog.51cto.com/9767314/1886538
SQL queries whether a table exists and returns the ID of the new data