June 5, 2009 at 10:02 am
Comments posted to this topic are about the item Table Generator for defined tables
June 11, 2009 at 3:48 am
I think the system generated would do fine for me.....but informative though ...
and I was wondering why not use the keyword QUOTENAME to get the table name in square brackets '[ ]'
May 19, 2010 at 5:34 am
thanks... but there is one issue though...
1. create some user defined types in your database say UdtIntEntity
2. when you execute this query, you will get one row for each type viz. Int, UdtIntEntity for the SAME table column.
May 19, 2010 at 5:37 am
ziangij (5/19/2010)
thanks... but there is one issue though...1. create some user defined types in your database say UdtIntEntity
2. when you execute this query, you will get one row for each type viz. Int, UdtIntEntity for the SAME table column.
try this code...
EXEC dbo.sp_addtype N'UdtIntEntity ', N'int',N'not null'
EXEC dbo.sp_addtype N'udtDesc', N'varchar(500)',N'not null'
EXEC dbo.sp_addtype N'udtName', N'varchar(500)',N'not null'
CREATE TABLE [dbo].[abc](
[col1] INT IDENTITY(1,1) NOT NULL
,[col2] VARCHAR(15) NOT NULL
,[col3] VARCHAR(500) NOT NULL
CONSTRAINT [PK_abc_col1] PRIMARY KEY CLUSTERED
(
[col1] ASC
)
)
then run your code for table abc...
the output will be something like this...
if not exists(select * from sysobjects where id = object_id('abc')
and objectproperty(ID, N'IsUserTable') = 1)
begin
Create Table dbo.abc
(
[col1] int NOT NULL IDENTITY (1, 1)
[col1] UdtIntEntity NOT NULL IDENTITY (1, 1)
,[col2] varchar(15) NOT NULL
,[col2] udtDesc NOT NULL
,[col2] udtName NOT NULL
,[col3] varchar(500) NOT NULL
,[col3] udtDesc NOT NULL
,[col3] udtName NOT NULL
)
May 24, 2010 at 7:42 am
Ryan,
In your article I see 'And, the script currently does handle foreign keys. ' Was there supposed to be a does not in there - I don't see the logic for scripting Foreign Keys.
Nice Work,
Doug
May 24, 2010 at 8:04 am
Correct. The script does not handle foreign keys. Thanks for catching that.
Thank you,
-Ryan Foote
May 19, 2016 at 7:02 am
Thanks for the script.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply