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.
| 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 doa "scripted" DDL-scripting? I mean, I have quite a number oftables in the DB I'm currently developing, and I was lookingfor 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 followingif 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__CONVENZIONIGOif 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__CONVENZIONIGOif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[_CONVENZIONI]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[_CONVENZIONI]GOCREATE 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 cyclethrough my tables and ready the files to be included in thedocumentation much more faster. I already have to do an awfullykind of work for each diagram! Any help is appreciate (and I hope my quick search of BOL didn'tturn 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 |
 |
|
|
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'lltry to use the multiple saves......amazing what a lack of time can do to the attention at thatlittle dials Thanks again,HCL"If it works fine, then it doesn't have enough features" |
 |
|
|
|
|
|
|
|