Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Table Generator for defined tables Expand / Collapse
Author
Message
Posted Friday, June 5, 2009 10:02 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, September 5, 2014 5:24 PM
Points: 4, Visits: 58
Comments posted to this topic are about the item Table Generator for defined tables
Post #729868
Posted Thursday, June 11, 2009 3:48 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, June 4, 2014 3:27 AM
Points: 313, Visits: 382
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 '[ ]'
Post #732862
Posted Wednesday, May 19, 2010 5:34 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Sunday, November 2, 2014 11:03 PM
Points: 2,103, Visits: 371
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.
Post #924191
Posted Wednesday, May 19, 2010 5:37 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Sunday, November 2, 2014 11:03 PM
Points: 2,103, Visits: 371
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
)


Post #924195
Posted Monday, May 24, 2010 7:42 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-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
Post #926834
Posted Monday, May 24, 2010 8:04 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, September 5, 2014 5:24 PM
Points: 4, Visits: 58
Correct. The script does not handle foreign keys. Thanks for catching that.


Thank you,
-Ryan Foote
Post #926851
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse