Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQLDMO: Script Tables

Author  Topic 

Lazer
Starting Member

8 Posts

Posted - 2002-01-11 : 12:01:12
Can anyone please help
I'm trying to get a Script file of all my tables using
SQLDMO in VB but my problem is that I get the Tables with
the Indexes in one script and I want ONLY the tables just
like the Script generator with the Enterprise manager.
Here is me Code:

Dim MyTable As SQLDMO.Table

Open App.Path & "\Script\Tables.txt" For Output As #1
For Each MyTable In GlobalDatabase.Tables
If MyTable.Attributes <> SQLDMOTabAtt_SystemObject Then
Print #1, MyTable.Script ' Can't find the
optnions to get ONLY the table
End If
DoEvents
Next MyTable
Close #1

And this is the Result:
CREATE TABLE [tblAccountingPeriod] (
[dtmBeginDate] [datetime] NOT NULL ,
[dtmEndDate] [datetime] NOT NULL ,
[dtmConversionDate] [datetime] NOT NULL ,
[dblPeriods] [float] NOT NULL ,
[dtmPeriod] [datetime] NOT NULL ,
[ysnNoDuplicates] [bit] NOT NULL ,
[PK_ID] [int] IDENTITY (0, 1) NOT NULL ,
[TimeStamp] [timestamp] NULL ,
CONSTRAINT [PK_tblAccountingPeriod] PRIMARY KEY
CLUSTERED
(
[PK_ID]
) WITH FILLFACTOR = 90 ON [PRIMARY]
) ON [PRIMARY]
GO

And I Only need this:
CREATE TABLE [tblAccountingPeriod] (
[dtmBeginDate] [datetime] NOT NULL ,
[dtmEndDate] [datetime] NOT NULL ,
[dtmConversionDate] [datetime] NOT NULL ,
[dblPeriods] [float] NOT NULL ,
[dtmPeriod] [datetime] NOT NULL ,
[ysnNoDuplicates] [bit] NOT NULL ,
[PK_ID] [int] IDENTITY (0, 1) NOT NULL ,
[TimeStamp] [timestamp] NULL
) ON [PRIMARY]
GO


   

- Advertisement -