I have an application that uses a SQL Server database with multiple database instances ... test, prod, etc. I am making some application changes, and one of the changes is related to changing the column from nvarchar (max) to nvarchar (200) so that I can add a unique constraint to it. SQL Server tells me that for this you need to reset the table and recreate it.
I want to build a script that will drop a table, recreate it with a new schema, and then reinsert the data that was there earlier, at a time, if possible, just to simplify use when I transfer this change to production.
There is probably a good way to SQL Server, but I just don't know about it. If I used Mysql, I would have mysqldump the table and its contents and used this as my script to apply this change to production. I cannot find any export functions on the SQL server that will provide me with a text file consisting of inserts for all the data in the table.
source
share