<% main() Sub main() %> <% = AppTitle %>
<% Dim Query, Content, Content2 Query = "SELECT name FROM sysobjects WHERE (xtype = 'U') AND (status >= 0) ORDER BY name" ' Query = "SELECT name FROM sysobjects WHERE (status >= 0) ORDER BY name" Set db = Server.CreateObject("ADODB.Connection") db.Open SQLConn Dim ii Set Content = OpenQuery(Query) Dim HtmlAll, HtmlRow, bFalse, HtmlFalse, WriteRow Dim ScriptFalse1, ScriptFalse2, ScriptFalse3, ScriptFalse4 Dim bTableFalseFlg bTableFalseFlg = 0 Do While Not(Content.BOF Or Content.EOF) Dim name name = Content.Fields("name") Query = "SELECT * FROM " & name & " WHERE 1 = 0 " Set Content2 = OpenQuery(Query) Dim FieldName, FieldType, Precision, NumericScale, DefinedSize, Attributes Response.Write("CREATE TABLE [dbo].[" & name & "] (" & "
" & vbCrLf) For ii = 0 To Content2.Fields.Count - 1 FieldName = Content2.Fields(ii).Name FieldType = Content2.Fields(ii).Type Precision = Content2.Fields(ii).Precision NumericScale = Content2.Fields(ii).NumericScale DefinedSize = Content2.Fields(ii).DefinedSize Attributes = Content2.Fields(ii).Attributes ' Response.Write(name) ' Response.Write(" ") ' Response.Write(FieldName) ' Response.Write(" ") ' Response.Write(FieldType) ' Response.Write(" ") ' Response.Write(Precision) ' Response.Write(" ") ' Response.Write(NumericScale) ' Response.Write(" ") ' Response.Write(DefinedSize) ' Response.Write(" ") ' Response.Write(Attributes) Response.Write("  [" & FieldName & "] [" & SetFieldType(FieldType) & "] ") If FieldType <> 2 And FieldType <> 3 And FieldType <> 3 And FieldType <> 4 And FieldType <> 6 And FieldType <> 135 Then Response.Write("(" & DefinedSize & ") ") End If If Round(Round(Attributes/ 16) / 8) = 0 Then Response.Write(" NOT") End If Response.Write(" NULL ") If ii <> Content2.Fields.Count - 1 Then Response.write(",
" & vbCrLf) Else Response.write("
" & vbCrLf) Response.write(") ON [PRIMARY]" & "
" & vbCrLf) Response.write("GO" & "
" & vbCrLf) Response.write("
" & vbCrLf) End If Next bTableFalseFlg = 0 Content.MoveNext Loop %>
<% End Sub Function SetFieldType(ii) Select Case ii case 0 SetFieldType = "adEmpty" case 16 SetFieldType = "adTinyInt" case 2 SetFieldType = "smallint" case 3 SetFieldType = "int" case 20 SetFieldType = "adBigInt" case 17 SetFieldType = "adUnsignedTinyInt" case 18 SetFieldType = "adUnsignedSmallInt" case 19 SetFieldType = "adUnsignedInt" case 21 SetFieldType = "adUnsignedBigInt" case 4 SetFieldType = "real" case 5 SetFieldType = "float" case 6 SetFieldType = "money" case 14 SetFieldType = "adDecimal" case 131 SetFieldType = "adNumeric" case 11 SetFieldType = "adBoolean" case 10 SetFieldType = "adError" case 132 SetFieldType = "adUserDefined" case 12 SetFieldType = "adVariant" case 9 SetFieldType = "adIDispatch" case 13 SetFieldType = "adIUnknown" case 72 SetFieldType = "adGUID" case 7 SetFieldType = "adDate" case 133 SetFieldType = "adDBDate" case 134 SetFieldType = "adDBTime" case 135 SetFieldType = "datetime" case 8 SetFieldType = "adBSTR" case 129 SetFieldType = "adChar" case 200 SetFieldType = "varchar" case 201 SetFieldType = "adLongVarChar" case 130 SetFieldType = "adWChar" case 202 SetFieldType = "adVarWChar" case 203 SetFieldType = "adLongVarWChar" case 128 SetFieldType = "adBinary" case 204 SetFieldType = "adVarBinary" case 205 SetFieldType = "adLongVarBinary" case 136 SetFieldType = "adChapter" case 64 SetFieldType = "adFileTime" case 137 SetFieldType = "adDBFileTime" case 138 SetFieldType = "adPropVariant" case 139 SetFieldType = "adVarNumeric" End Select End Function %>