Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #2124

Re: VO2ADO Add Colum To Existing Table

From "Willie Moore" <williem@wmconsulting.com>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: VO2ADO Add Colum To Existing Table
Date 2011-10-01 20:44 -0500
Organization Aioe.org NNTP Server
Message-ID <j68fl2$4cp$1@speranza.aioe.org> (permalink)
References <a2259ad4-7b9f-443a-985c-5503010d71e6@dd6g2000vbb.googlegroups.com> <4e876e00$0$32167$c3e8da3$40d4fd75@news.astraweb.com>

Show all headers | View raw


Ginny,

I use almost the same exact code in my apps to handle changes in the 
structure. I don’t trust most system admins to properly run my update 
scripts.

Regards,
Willie

"Ginny Caughey"  wrote in message 
news:4e876e00$0$32167$c3e8da3$40d4fd75@news.astraweb.com...

Here's a line from my production app:

s :=    "  if not exists(select * from information_schema.columns where
column_name = 'CashAmt' and table_name = 'History')"+;
        "    alter table History add CashAmt decimal(12,2)  NOT NULL
DEFAULT(0) "
gConn:Execute(s)

Ginny

"Ian"  wrote in message
news:a2259ad4-7b9f-443a-985c-5503010d71e6@dd6g2000vbb.googlegroups.com...

Hi,

I am trying to add a column to an existing sql server 2008 table, if
that column name does not already exist. But I am getting error
messages. The code I am using is as follows;

aSqlArray :={}
cNewSql :=" if NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMN
WHERE TABLE_NAME ;
= [Whstocks] AND COLUMN_NAME = [TOPVALUE])"
cNewSql +=" BEGIN"
cNewSql +=" ALTER TABLE WHSTOCKS"
cNewSql +=" ADD TOPVALUE [int] NULL"
cNewSql +=" END"
AAdd(aSqlArray,cNewSql)
lResult :=CreateSqlTables(aSqlArray,"",oDataConn)

The code between BEGIN and END works ok, the error is in the IF NOT
EXISTS line. Error reports problem next to keywork COLUMN. Could
someone show me some code that checks to see if a column exists in an
sql server table, and if not it adds the column to the table.

Regards,
Ian 

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

VO2ADO Add Colum To Existing Table Ian <ithomson@mikroaid.co.uk> - 2011-10-01 09:19 -0700
  Re: VO2ADO Add Colum To Existing Table "Ginny Caughey" <ginny.online@hotmail.com> - 2011-10-01 15:49 -0400
    Re: VO2ADO Add Colum To Existing Table "Willie Moore" <williem@wmconsulting.com> - 2011-10-01 20:44 -0500
      Re: VO2ADO Add Colum To Existing Table Ian <ithomson@mikroaid.co.uk> - 2011-10-02 04:21 -0700
  Re: VO2ADO Add Colum To Existing Table "Willie Moore" <williem@wmconsulting.com> - 2011-10-01 20:39 -0500

csiph-web