Wht's wrong with this sql statement. Does not run

  • Hi

    Wht's wrong with this sql statement. Does not run on sql server 7.

    if not exists(SELECT * FROM [HISPos].[dbo].[syscolumns]

    where name='RecordVoidSale')

    begin

    alter table HISPOSControl add RecordVoidSale bit default 0

    update hisposcontrol set RecordVoidSale=0

    end

    Error says no column named RecordVoidSale

    Can you help me out?

    Regards

    Mani

  • SQL Server is looking for the recordvoidsale column before it is added. Instead, try ....

    if not exists(SELECT * FROM [HISPos].[dbo].[syscolumns]

    where name='RecordVoidSale')

    begin

    alter table HISPOSControl add RecordVoidSale bit default 0

    exec ('update hisposcontrol set RecordVoidSale=0')

    end

    HTH

    Billy

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply