|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, February 13, 2013 11:01 AM
Points: 4,
Visits: 57
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Saturday, March 02, 2013 8:26 PM
Points: 312,
Visits: 367
|
|
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 '[ ]'
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:53 AM
Points: 1,528,
Visits: 359
|
|
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.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:53 AM
Points: 1,528,
Visits: 359
|
|
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 )
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, January 26, 2011 1:32 PM
Points: 146,
Visits: 327
|
|
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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, February 13, 2013 11:01 AM
Points: 4,
Visits: 57
|
|
Correct. The script does not handle foreign keys. Thanks for catching that.
Thank you, -Ryan Foote
|
|
|
|