Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Generate DDL script to create table and all constraints


Generate DDL script to create table and all constraints

Author
Message
VPSD
VPSD
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 136
Comments posted to this topic are about the item Generate DDL script to create table and all constraints
ocp_yang
ocp_yang
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 62
right? this scrips?
ESL_HSBC
ESL_HSBC
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 151
Hello many pb when compiling SP

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 13
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 21
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 22
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 22
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 23
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 23
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 24
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 24
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 26
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Line 28
Incorrect syntax near ' '.
Msg 137, Level 15, State 2, Line 32
Must declare the scalar variable "@Create_Table_Ind".
Msg 156, Level 15, State 1, Line 76
Incorrect syntax near the keyword 'THEN'.
Msg 137, Level 15, State 2, Line 88
Must declare the scalar variable "@PK_Ind".
Msg 137, Level 15, State 2, Line 150
Must declare the scalar variable "@FK_Ind".
Msg 137, Level 15, State 2, Line 194
Must declare the scalar variable "@Check_Ind".
Msg 137, Level 15, State 2, Line 213
Must declare the scalar variable "@Default_Ind".
Msg 102, Level 15, State 1, Line 252
Incorrect syntax near 'END'.
VPSD
VPSD
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 136
This SP should be used in SQL Server 2008 version and use the signature as mentioned at the end of the SP.
ESL_HSBC
ESL_HSBC
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 151
Hi,
thank's for response,

does it work in SQL2005 please ?
VPSD
VPSD
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 136
It can but the SP will have to be tweaked to make it work in 2005 ...
Greenius
Greenius
SSC Journeyman
SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)

Group: General Forum Members
Points: 80 Visits: 98
This is a great script - really helpful - thank you!

Can I suggest a tweak for computed columns too?

Computed columns get created as a regular columns such as varchar(100) but if you left join to sys.computed_columns and use the [definition] column you end up with a column definition like this:

[Fullname] AS (([Firstname]+' ')+[Lastname]),

Hope this helps someone else out there BigGrin
Richard Norris
Richard Norris
SSC Veteran
SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)

Group: General Forum Members
Points: 266 Visits: 190
Not sure if I have done something wrong here, but when generating the script for a table it's not generating the size for DECIMAL & NUMERIC columns?



VPSD
VPSD
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 136
Can you send the structure of your table?
Richard Norris
Richard Norris
SSC Veteran
SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)

Group: General Forum Members
Points: 266 Visits: 190
This is just a table I created to test:

CREATE TABLE [dbo].[Table_1](
[col1] [nchar](10) NOT NULL,
[col2] [numeric](25, 12) NULL,
[col3] [xml] NULL,
[col4] [decimal](18, 0) NULL,
[col5] [varchar](max) NULL,
[col6] [varbinary](50) NULL,
[col7] [money] NULL,
[col8] [ntext] NULL,
[col9] [text] NULL,
[col10] [float] NULL,
[col11] AS ([col5]+'aaa'),
[col12] [dbo].[ga_money] NOT NULL
)

Obviously ga_money is a user defined data type



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search