Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Need help with complex column creation command

Hello, all

I need help with a complex column creation command and SQL anywhere help is not sufficient for it.

Here is the situation:

I need to write a generic DDL "alter table" command, which can add/modify columns without knowing in advance if they already exist in the destination table.

Is there a command, which looks like:

alter table "table1" add (on existing modify) column1 <datatype> <default> ?

Thank you,


Former Member replied


I don't think this is supported in alter table command. But you can code that inside an if statement which queries systables & syscolumns. Your code should be something like that:

if (select count(*) from sysobjects, syscolumns where = and = 'some_table' and = 'some_column') < 1


    alter table some_table add some_column numeric(12) not null


This is an example..


0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question