Tuesday, November 3, 2009

VB Code to generate Create Script for the Table

Dim Server As New SQLDMO.SQLServer, Database As New SQLDMO.Database, Table As New SQLDMO.Table
Dim Server_Name As String, Login_Name As String, Password As String, Database_Name As String, Table_Name As String

Server_Name = Text3
Login_Name = Text1
Password = Text2
Database_Name = Text4
Table_Name = Text5
Server.Connect Server_Name, Login_Name, Password
Set Database = Server.Databases(Database_Name)
Set Table = Database.Tables(Table_Name)
MsgBox Table.Script
Debug.Print Table.Script


Set Table = Nothing
Set Database = Nothing
Server.DisConnect
Set Server = Nothing

No comments: