Error 15335 - is already in use as a object name...

  • I am getting this error:

    Error 15335 - is already in use as a object name...

    when trying to rename a view in sql2005.

    The view name does not appear in the list in object explorer.

    If I run this query:

    select * from sysobjects where name like '%myView_ForumPermissions%'

    - I can then see the view.

    If I run this query to remove it:

    TRUNCATE table myView_ForumPermissions

    - it says it ran succsessful, but it doesn not actually delete it.

    The reason for removing it is because I am changing schemas from one schema to another (becasue after several upgrades some views and stored procedures are not using the intended .dbo schema, so i'm finding the missing ones and copying across).

  • mrichardson 57577 (11/8/2012)


    I am getting this error:

    Error 15335 - is already in use as a object name...

    when trying to rename a view in sql2005.

    The view name does not appear in the list in object explorer.

    If I run this query:

    select * from sysobjects where name like '%myView_ForumPermissions%'

    - I can then see the view.

    If I run this query to remove it:

    TRUNCATE table myView_ForumPermissions

    - it says it ran succsessful, but it doesn not actually delete it.

    The reason for removing it is because I am changing schemas from one schema to another (becasue after several upgrades some views and stored procedures are not using the intended .dbo schema, so i'm finding the missing ones and copying across).

    TRUNCATE does not remove objects.

    Try DROP VIEW

  • A view is exactly that, a constructed view of the underlying tables, essentially a saved or materialized SQL (SELECT) query.

    If you want to truncate the view, then really you should truncate the underlying tables, not the view itself (obviously you can delete rows from a view which may filter to the underlying table provided it meets certain conditions) - I don't think that even if the conditions are met, that can apply the TRUNCATE command to the view and affect the underlying table.

    As indicated in previous answer - you can drop the view - again, by doing so, you will not have any impact on the underlying tables/data.

    Saying that, the error message displayed is a little poor, which doesn't help,

    HTH,

    B

  • thanks for the replies.

    it turns out that the name of my view had been created in error as a table, thats why i couldn't see it in the object explorer window.

    therefore used drop table and then managed to re-create the view.

Viewing 4 posts - 1 through 3 (of 3 total)

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