#SQL SERVER
private string sqltablelist = @ "Select
So.name,
Convert (VARCHAR), ep.[ Value]) as [description]
From
sysobjects SO (NOLOCK)
Left JOIN sys.extended_properties EP (NOLOCK) on Ep.major_id=so.id and Ep.minor_id=0
WHERE
So. [type]= ' U ' and so.name<> ' Sysdiagrams '
ORDER by
So.name ";
private string sqlfieldlist = @ "Select
C.name,
T.name as [type],
C.length as MaxLength,
C.isnullable as IsNullable,
(
SELECT COUNT (1) from Sys.identity_columns IC (NOLOCK) WHERE IC. [Object_id]=c.id and Ic.column_id=c.colid
) as Isidentity,
(
SELECT VALUE from Sys.extended_properties EP (NOLOCK) WHERE ep.major_id = C.id and Ep.minor_id=c.colid
) as [description],
[Ispk]=case when EXISTS (SELECT 1 from sysobjects WHERE xtype= ' PK ' and Parent_obj=c.id and name in (
Select name from sysindexes where Indid in (SELECT indid from Sysindexkeys where id = c.id and colid=c.colid)) then 1 ELSE 0 END
From
syscolumns C (NOLOCK)
INNER JOIN sys.tables ts (NOLOCK) on TS. [OBJECT_ID] = C.id
INNER JOIN sys.types T (NOLOCK) on T.system_type_id=c.xtype
INNER JOIN systypes St (NOLOCK) on st.name=t.name and st.name<> ' sysname '
INNER JOIN sysusers su (NOLOCK) on st.uid=su.uid and su.name= ' sys '
--inner JOIN syscolumns S (NOLOCK) on c.[object_id]=s.id
WHERE
Ts.name= ' {0} '
ORDER by
C.id ASC ";
#MySQL
private string sqltablelist_mysql = @ "Select
table_name as NAME,
Table_comment as Description
From
Information_schema. TABLES
WHERE
Table_schema= ' {0} ';
private string sqlfieldlist_mysql = @ "Select
column_name as NAME,
Data_type as TYPE,
Ifnull (character_maximum_length,0) as MaxLength,
(Case is_nullable if ' NO ' then 0 ELSE 1 END) as isnullable,
As Isidentity,
Column_comment as Description,
(Case Column_key "PRI" then 1 ELSE 0 END) as ISPK
From
Information_schema. COLUMNS
WHERE
Table_schema= ' {0} '
and Table_name= ' {1} '
ORDER by
Ordinal_position ASC ";
#endregion
Code generator SQL Server and Mysql database scripts