Search code examples
sybasesap-ase

How to add two columns to a table


I have a table. I want to add two columns to this table.

I tried it like this:

SELECT * 
into
dbo.mytable_Audit
from dbo.mytable

But, I need two colums to mytable_Audit, how do I add them in sybase 15-2 ASE?


Solution

  • You get as much columns in your new table, as you have in the existing one. Name, type and order will be inherited from dbo.mytable. To add an additional column to the output, just add a column to the select:

    select 0 as col1, * into dbo.mytable_AUDIT from dbo.mytable;

    This adds a column of type integer as the first column in the new table.