dbTalk Databases Forums  

db upgrade code

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss db upgrade code in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jeff Kish
 
Posts: n/a

Default db upgrade code - 05-16-2006 , 03:35 PM






Hi.
There are 3 systems a customer might have:
ancient, old, and new.

I'm trying to write a t-sql script which will be safe to run on any of the 3,
and upgrade appropriately.

unfortunately, I find that if I have a script like this, it won't compile if
running against a new system lacking col1:

if exists (informationschema....columns..)/*missing*/
begin
create table table0 col2 varchar(60)
end
else
if exists (informationschema...columns..)/*ancient*/
begin
alter table add col2 varchar(60)
update table set col2 = col1
alter table drop col1
some other stuff
end
else
if exists (informationschema...columns..)/*old*/
begin
some other stuff
end

Is there someway of writing some code to update correctly using t-sql and
handling this?

thanks
Jeff Kish

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.