Citation: Http://www.2cto.com/database/201209/155178.htmlSQL statement gets all database names, table names, field names, table fields length gets all the tables in the database select Sysobjects.name as Tablename from sysobjects WHERE xtype = ' U '
Get column names for all tables in the database select Syscolumns.name as Columnsname, sysobjects.name as Tablename from SysObjects, syscolumns WHERE S Ysobjects. Xtype= ' u ' and sysobjects.id=syscolumns.id www.2cto.com get SQL all database names, all table names, all field names, table field lengths 1. Get all database names in MSSQL: SELECT name from MASter. sysdatabases ORDER by name 2. Gets all user table names in MSSQL: SELECT name from DatabASename. SysObjects WHERE xtype= ' u ' ORDER by namextype= ' U ': represents all user tables; Xtype= ' S ': represents all system tables; 3. Gets all field names for the specified table [Tb_phone]: SELECT name from syscolumns WHERE id=object_id (' Tb_phone ') 4. Table name of all SQL tables, all field names, table field lengths select TABLE_NAME as data table name, column_name as field name, ISNULL (Column_default, ") as default, is_nullable as is allowed for Null, data_type as data type, ISNULL (ISNULL (ISNULL (character_maximum_length,numeric_precision), datetime_ Precision), 1) as type length from Information_schema.columnswhere not table_name in (' Sysdiagrams ', ' dtproperties ') 5. Gets the table name of the specified table [Tb_phone], the field type and the type length of the name, select Sysobjects.name as tablename,syscolumns.name as columnsname,systypes.name as Datetype,syscolumns.length As datelength www.2cto.com from sysproperties right OUTER joinsysobjects INNER joinsyscolumns on sysobjects.i D = syscolumns.id INNER joinsystypes on syscolumns.xtype = Systypes.xtype onsysproperties.id = syscolumns.id AND&NBSP;SYSP Roperties.smallid = syscolumns.colidwhere (Sysobjects.xtype = ' u ' orsysobjects.xtype = ' V ') and (Systypes.name <> ' S Ysname ') and (sysobjects.name = ' tb_phone ') ORDER by Columnsname
SQL statement gets all database names, table names, field names, table fields length