October 6, 2011 at 2:23 am
Hi,
Is there any easy way to copy only the conten of databases like tables structures and others with no data? Do I need to truncate all the tables individually?
Ryan
//All our dreams can come true, if we have the courage to pursue them//
October 6, 2011 at 4:25 am
Script out the database. Like it says above, use SSMS to generate a script. You can also make calls to SQL Server Management Objects (SMO) from code to generate scripts.
You might want to look into a 3rd party tool like Red Gate SQL Compare[/url]. That can help you just move the internal objects between two databases, no data.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 6, 2011 at 11:41 pm
You could accomplish this two ways:
Option #1
- Create a script to drop all your FK constraints
- Create a script to create all your FK constraints
To do this, right click on the database and "Generate Scripts.."
Then
- Run your script to drop all Fks
- Use the sp_MSForEachTable stored procedure to truncate all tables for each Database (obvioulsy you want to avoid all system DBs) Ex: EXEC sp_MSForEachTable 'Truncate Table ?'
- Run your script to add all the FKs back
Option #2
Generate a script to DROP and CREATE all your tables in the database, run them. All data is gone.
Backup the database, then restore it elsewhere. This will preserve all your stored-procs, functions, views, and so forth...
______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply