SELECT * from Master. sysdatabases ORDER by NameSelect Name,* from Master. sysdatabases where name='TestDB'%testdb% ' *'%com_userlogin%'
stringConnectionString ="server=.; Uid= '"+ UID +"'; Pwd= '"+ pwd +"';D atabase= '"+ DB +"'"; string[] restriction =New string[4]; restriction[1] ="dbo"; SqlConnection Conn=NewSqlConnection (connectionString); Conn. Open (); DataTable DT= Conn. GetSchema ("Tables", restriction);
SELECT ( CaseWhen a.colorder=1Then D.nameElse "'end) Table name, A.colorder field ordinal, a.name field name, ( CaseWhen ColumnProperty (A.id,a.name,'isidentity')=1Then'√'Else "'end) identification, ( CaseWhen (SELECT count (*) from sysobjects WHERE (nameinch(SELECT name from sysindexes WHERE (ID= a.ID) and (indidinch(SELECT indid from Sysindexkeys WHERE (ID= a.ID) and (colidinch(SELECT colid from syscolumns WHERE (ID= a.id) and (name =A.name))))) and (Xtype='PK') ) >0Then'√' Else "'end) Primary key, B.name type, A.length occupies the number of bytes, ColumnProperty (A.id,a.name,'PRECISION') aslength, IsNull (ColumnProperty (A.id,a.name,' Scale'),0) asNumber of decimal digits, ( CaseWhen a.isnullable=1Then'√'Else "'end) allow null, IsNull (E.text,"') Default value, IsNull (G.[value],"'As field description from syscolumns a LEFT join systypes B on A.xtype=b.xusertype INNER join sysobjects D on a.id=d.id and D.xtype='U'and d.name<>'dtproperties'Left join syscomments e on A.cdefault=E.id left Join Sys.extended_properties G on a.id=g.major_id and A.colid =g.minor_id--whereD.nameinch(' Contact','Stockbmps','addresstype')---Query the specific table, comments out after the entire database is queried order by A.id,a.colorder
SQL Server 2008 Query data field name type