Click here to Skip to main content
15,909,586 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We have a one Sql server db, Now we have changed in the db table schema and stored procedure so we are try to update db schema only without losing data.
Is it possible?
If Yes then how?


What I have tried:

we tried out everything what we can.
Posted
Updated 18-Jun-18 8:08am
Comments
Naga Sindhura 18-Jun-18 8:53am    
check this one once. It may help you.
https://stackoverflow.com/questions/17571233/how-to-change-schema-of-all-tables-views-and-stored-procedures-in-mssql
MadMyche 18-Jun-18 9:51am    
What type of schema changes are needed? Posting before/after DDLs would be helpful.

1 solution

What did you try? Usually, it's a very simple thing to do.

For example, if you added a column then do:
SQL
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'some_column' AND Object_ID = Object_ID(N'dbo.[some_table]'))
BEGIN
	ALTER TABLE [some_table] ADD some_column VARBINARY(MAX) NULL
END
GO


or if you are altering a column that will not lose data with the new data type do
SQL
ALTER TABLE someTable ALTER COLUMN someColumn NVARCHAR (MAX) NULL
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900