Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Modify Table Structure via Stored Procedure(?)

Author  Topic 

Metcalf
Yak Posting Veteran

52 Posts

Posted - 2008-06-09 : 10:44:42
Our ERP vendor is helping us migrate from one version of their product to another. In the new version, they have added some columns and changed a few data types in several existing tables.

They sent us a list of the modifications that were necessary, which we did (painstakingly) by hand. But, for other reasons the update failed and we have to start anew.

This got me thinking: is there any way to do this kind of update via a script/stored procedure? I don't have their exact changes handy, but it was stuff like the table "inmast" needs a column of varchar(50) called "lotc" added to it, and the "intime" table needs the datatype of columns "Mon" "Tue" "Wed" changed from text to varchar(50), stuff like that.

Is it possible to do stuff like that in a SP?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-09 : 10:49:47
ALTER TABLE MyTable
ALTER COLUMN MyColumn NewDataType {(precision)}

perhaps?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -