winmyan
asked on
SQL Server - Keep track of changes in Management Studio as sql command
In SQL server 2000, I'm adding some columns into tables using Management Studio. Is there any way I can get the changes into a sql script, so that I can run the script in another sql server.
Basically, I want to sql server to generate a script for me whatever I have done in sql mangement studio. Is that possible?
Thank in advance!
Basically, I want to sql server to generate a script for me whatever I have done in sql mangement studio. Is that possible?
Thank in advance!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No... Before saving your table changes there is a button to save as change script.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, that's in SQL 2005.
In 2000
It is right below the Window Menu bar item.
In 2000
It is right below the Window Menu bar item.
ASKER
After adding columns into the existing table, I generated the script.
In the script, the temporary table is created first and copy the existing data into the temp table. Then delete the exisiting table and rename the temporary table to the deleted (old) table name.
Is it how the script is always generated (for adding columns into existing table)? Is it acceptable behavior? Does it (negative) affect in Referential integrity?
Thank you all for your responses...
In the script, the temporary table is created first and copy the existing data into the temp table. Then delete the exisiting table and rename the temporary table to the deleted (old) table name.
Is it how the script is always generated (for adding columns into existing table)? Is it acceptable behavior? Does it (negative) affect in Referential integrity?
Thank you all for your responses...
I bet you attempted to inject a column in the middle, instead of appending it to the end. If you do, that is how it will be done. You can add on to the end without it having to go through those steps.
ASKER
Hi BrandonGalderisi,
Yes, I'm trying to insert columns in the middle becuase I want the last column to be DateCreated. :)
Is there any work around? Thank you for your answer.
Yes, I'm trying to insert columns in the middle becuase I want the last column to be DateCreated. :)
Is there any work around? Thank you for your answer.
No, there is no workaround (except the REALLY BAD IDEA I MENTION BELOW). Also, why are you so caught up on the order of your columns. You can select them out in any way you desire and since you should always be specifying a field list when you do an insert, that doesn't matter either.
If all you care about is putting it before the LAST column, you can always:
drop any constraints or indexes that reference datecreated
rename the column
add the new column
add the datecreated column
move the data from the old datecreated column
drop the old datecreated column
reapply any indexes and constraints
but again, why worry, the order of the fields in the table doesn't matter.
If all you care about is putting it before the LAST column, you can always:
drop any constraints or indexes that reference datecreated
rename the column
add the new column
add the datecreated column
move the data from the old datecreated column
drop the old datecreated column
reapply any indexes and constraints
but again, why worry, the order of the fields in the table doesn't matter.
ASKER
Thank you all for your Comments!
ASKER
Thank both of you for your help!