- For example, in Table A to judge whether there is a field C two methods: one, the IF EXISTS ( the SELECT . 1 the FROM the SYSOBJECTS Tl the INNER the JOIN The SYSCOLUMNS T2 the ON t1.id = t2.ID the WHERE t1.name = ' A ' the AND T2 .NAME = ' C ' ) the PRINT ' presence ' the ELSE the PRINT ' absent ' two, dapper, described classical the IF COL_LENGTH ( ' A ' , 'C ' ) the IS the NOT NULL the PRINT N ' presence ' the ELSE the PRINT N ' absent ' Method a: SELECT * from the syscolumns WHERE ID = object_id ( ' table ' ) and name = ' Column name ' Description: The presence of this column is returned a note record, return empty absent; method two: SELECT COUNT ( * ) from the sysobjects A, B the syscolumns WHERE a.id= B.id and b.name = ' FLAG1 ' and a.type = ' U ' and a.name = ' T_Pro_ProductClass ' Description: Returns 1 is present, there is no return 0
SQL Server table to determine whether there is a field [turn]
Guess you like
Origin www.cnblogs.com/howie-we/p/12089093.html
Recommended
Ranking