making back up copy of sql server tables to include data and all associated table objects

blossompark
blossompark used Ask the Experts™
on
Hi,
I’ve made some changes to some SQL Server objects, tables,views, stored procedures, functions etc in my test environment which I now want to move to the production environment.
I want to make backups of the existing objects in production, eg Production_Table_1 as Production_Table_1_backUp.
I’m looking for the easiest way to make a copy of the table in its existing database, and the copy to include all associated indexes,constraints, data etc…
I looked at Transfer SQL Server Object Tasks in SSIS but it doesn’t seem to allow altering the object name.
I’m now looking at using  the “Script Table as” option in Management studio but it doesn’t seem to copy indexes.
Any guidance appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
lcohanDatabase Analyst

Commented:
You could use COPY database or FULL database BACKUP and RESTORE for that matter:

https://docs.microsoft.com/en-us/sql/relational-databases/databases/use-the-copy-database-wizard?view=sql-server-2014

Author

Commented:
thank you for that Icohan, as I am only changing a few objects I thought of backing them up individually, but this makes sense too, will look into this and get back to you
Database Analyst
Commented:
Unfortunately since first major rewrite of SQL (version 2000) that (very usefull) piece of functionality to selectively backup objects was taken away which means in current versions to date these options are the two easiest/quickest available that I can think off even though they most likely would get lots of unchanged(and not needed to be saved in this particular case) objects.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Author

Commented:
The Copy Database wizard is not allowing me to create user tables....it creates system tables, system views etc., but no user tables or user views.
it writes to a log...but i cannot access the log file as it is on a server that i do not have access to

Author

Commented:
I have only dbo access, this does not allow me to use the copy database wizard fully I believe
lcohanDatabase Analyst

Commented:
in that case your options are to ask for elevated permissions or ask for someone that has that to COPY DATABASE for you or go back to and re-do the SSIS and please see here how you can select what needs to be copied from source to target for each table as it is more than just the indexes you want to bring accross - PKeys, FKeys, Constraints, defaults, ETC...

http://www.kodyaz.com/articles/transfer-sql-server-objects-task.aspx

Author

Commented:
Hi Icohan, I backed up the objects individually as this proved to be the quickest under the circumstances....thanks for your input

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial