I'm new to all things Microsoft...and I've been struggling for hours figuring out how to use SQL Server Management Studio 2008 to export a database and import it into another database server. I'm a LAMP developer, so if this were a mysql database, I'd type the following into shell terminal:
mysqldump -u src_dbuser -psrc_password -h src_dbserver src_dbname > export.sql
mysql -u dest_dbuser -pdest_password -h dest_dbserver dest_dbname < export.sql
How do I perform the equivalent task in SQL Server? I've tried so many things and they all failed. Example of things my team tried in SQL Server Management Studio:
1) My client right clicked the database, chose "tasks", chose "generate scripts...", then followed the steps outlined in subsequent pop up windows. In doing so, we got an sql file of the db-schema and all the stored procedures, but it was missing all the data. We didn't see options to export the data.
2) So my client decided to export the data as an excel file. When I tried to import the excel file, one of the entity records violated a db constraint. The excel file had an "empty cell" for a field that was to be mapped to a non-nullable column in the corresponding database table. This one record stopped and exited from the remaining import process. I couldn't figure out how to tell Sql Server Management Studio to ignore this one record and proceed with importing the rest of the data.
3) I then tried to do an export myself remotely from home, just to see if my client missed something. On reproducing the steps outlined in Step 2), I got a new error when exporting
Microsoft.SqlServer.Management.Smo.SmoException: Could not read metadata, possibly due to insufficient access rights. at Microsoft.SqlServer.Management.SqlScriptPublish.GeneratePublishPage.worker_DoWork(Object sender, DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
I think I have all the access rights because I can successfully execute queries that perform CRUD operations. Not sure how else to confirm if I do or don't have access rights.
I've wasted so much time on this... I am so frustrated... Is Microsoft trying to make things exceedingly difficult? Can someone please tell me how to successfully import/export a database so that I can get back to doing what I love doing??? ie. DEVELOPING!!!
Additional information
OK, I tried the backup method as suggested by some people. That didn't work because SSMS was creating the backup file on the database server, as opposed to the HD of the computer I am working from. I do NOT have access to the file system on the database server, so that's why SSMS kept complaining it didn't have the privileges to write to any directories.