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)
 DDL scripting

Author  Topic 

HCLollo
Starting Member

49 Posts

Posted - 2005-10-06 : 07:11:52
Hi all!
Been a while without logging in, hope everyone's well!

Ok, I have a little problem: does anyone know how I could do
a "scripted" DDL-scripting? I mean, I have quite a number of
tables in the DB I'm currently developing, and I was looking
for an automated way to generate the definition script for each,
and save it automatically to a file, say '<TABLENAME>_def.txt'.

To be a little clearer, let's take a table at random, _CONVENZIONI.

I was looking forward to something that could write the following


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__EVENTI__CONVENZIONI]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[_EVENTI] DROP CONSTRAINT FK__EVENTI__CONVENZIONI
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__RATE__CONVENZIONI]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[_RATE] DROP CONSTRAINT FK__RATE__CONVENZIONI
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[_CONVENZIONI]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[_CONVENZIONI]
GO

CREATE TABLE [dbo].[_CONVENZIONI] (
[id] [smallint] IDENTITY (0, 1) NOT NULL ,
[pre_evento] [smallint] NOT NULL ,
[importo] [money] NOT NULL ,
[n_rate] [tinyint] NOT NULL
) ON [PRIMARY]
GO


to _CONVENZIONI_def.txt...maybe a SP exists? So I could cycle
through my tables and ready the files to be included in the
documentation much more faster. I already have to do an awfully
kind of work for each diagram!

Any help is appreciate (and I hope my quick search of BOL didn't
turn up anything because the info was really hidden )

Thanks in advance,

HCL


"If it works fine, then it doesn't have enough features"

Kristen
Test

22859 Posts

Posted - 2005-10-06 : 07:15:54
The Generate Script, in Enterprise Manager, has an option to output "each object to separate file" - would that do or do you need to automate it?

Kristen
Go to Top of Page

HCLollo
Starting Member

49 Posts

Posted - 2005-10-06 : 07:25:43
Thanks for the quick answer Kristen.

In truth the automation could help me a little, but for now I'll
try to use the multiple saves...

...amazing what a lack of time can do to the attention at that
little dials

Thanks again,
HCL


"If it works fine, then it doesn't have enough features"
Go to Top of Page
   

- Advertisement -