% main() Sub main() %>
<%
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 %> |