Drop column in SQL but not from Nav

Hi everyone.
I'm newbie in Nav, accidentally I've run SQL Command 'Alter Table [TableName] Dorp Column [ColumnName]'. But I have not deleted that column from Nav. And now, there are two errors appears when Im trying to drop that column and compiling object in Nav.
Errors:
5074, "42000", [Microsoft][ODBC SQL Server Driver][SQL Server] object "DF_LLC_Trad_Compa_7EEEF5F1" depends from column "Company" (Its my column name)
4922, "42000", [Microsoft][ODBC SQL Server Driver][SQL Server] Alter Table Dorp Column Company, because one or more objects access this column.
I've already tryed to export this object from backup database, but it didn't help
Is there any way to delete that column from Nav?

Thanks.
___________________
Nav 4.0
MS SQL Server 2008

Best Answer

  • PaulRoninPaulRonin Member Posts: 3
    Answer ✓
    The problem have been solved.
    I've run command -
    IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__LLC _Trad__Compa__7FEEF5F1]') AND type = 'D')
    BEGIN
    ALTER TABLE [dbo].[TableName] DROP CONSTRAINT [DF__LLC _Trad__Compa__7FEEF5F1]
    END

    GO

    Then i've deleted column from Nav with F4 button and compiled the object.

Answers

  • guillermoguillermo Member Posts: 1
    Hi,
    Try to recreate the column in sql server.
  • PaulRoninPaulRonin Member Posts: 3
    edited 2017-03-17
    guillermo wrote: »
    Hi,
    Try to recreate the column in sql server.

    I've already done this.
    The same error appears.
  • PaulRoninPaulRonin Member Posts: 3
    Answer ✓
    The problem have been solved.
    I've run command -
    IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__LLC _Trad__Compa__7FEEF5F1]') AND type = 'D')
    BEGIN
    ALTER TABLE [dbo].[TableName] DROP CONSTRAINT [DF__LLC _Trad__Compa__7FEEF5F1]
    END

    GO

    Then i've deleted column from Nav with F4 button and compiled the object.
  • krikikriki Member, Moderator Posts: 9,112
    Lesson learned: NEVER do something on NAV tables directly in SQL. Always do it from NAV. And that includes also indexes. (Index rebuild/defrag and statistics are ok to do directly in SQL).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.