Friday, March 9, 2012

Generate SQL script and columns order

I am using Generate SQL script or scptxft tool for generartion creation
script for my database.
But unfortunally this script generates order for columns in creating
table not saticfying me. I need to have order exactly like I see in
Enterprise Manager, but the default order is other...
Can anybode give an advise how solve this problem?
Hi,
I think you can not.
Try doing a reverse engineering if you have Erwin data modeller or else you
have to arrange manually.
Thanks
Hari
SQL Server MVP
"Sergi Adamchuk" <adamchuk@.gmail.com> wrote in message
news:1126006864.707536.128230@.o13g2000cwo.googlegr oups.com...
>I am using Generate SQL script or scptxft tool for generartion creation
> script for my database.
> But unfortunally this script generates order for columns in creating
> table not saticfying me. I need to have order exactly like I see in
> Enterprise Manager, but the default order is other...
> Can anybode give an advise how solve this problem?
>
|||Sergi Adamchuk wrote:
> I am using Generate SQL script or scptxft tool for generartion
> creation script for my database.
> But unfortunally this script generates order for columns in creating
> table not saticfying me. I need to have order exactly like I see in
> Enterprise Manager, but the default order is other...
> Can anybode give an advise how solve this problem?
I just did a little digging into the SQL EM Generate SQL Scripts and the
Design Table functions to see how they were querying the list of columns
in the tables for display.
It appears they are both using the sp_MShelpcolumns system procedure
with the OrderBy column specified as 'id'. With that parameter, you
should be seeing the order of the columns as they are ordered by their
ColID in syscolumns.
I tested on SQL Server 2000 SP4 (Server and Client Tools). If you are
not seeing the same result from those two functions, can you tell me:
1- Are you running SP4 on the server and/or the client
2- What do you see as the column order when you query the syscolumns
table for the table in question and order by the ColID column? Which
version of the output is correct and which is incorrect?
You can use:
Select name from syscolumns where id = object_id('<table_name>') order
by colid
David Gugick
Quest Software
www.imceda.com
www.quest.com

No comments:

Post a Comment