HOW CAN I CREATE A SQL SERVER SYSTEM TABLE

Chintoo Semi

Total Post:135

Points:947
Posted by  Chintoo Semi
 920  View(s)
Ratings:
Rate this:
I am developing a site that uses Entity Framework code first with migrations. After each major release, I take a copy of the production data and set it up in my development environment. I've found that in order to use a production data copy with migrations, it is necessary to copy the __MigrationHistory table from the old development database image to the production database copy.

This works fine, except for one annoying detail: the _MigrationHistory table comes across as a user table instead of a system table. This is not a serious problem as long as I remember to filter it out of my database diffs. But I would prefer to have the new __MigrationHistory table be a system table, just as it is in a database that was created by EF migrations.

Is there a way I can create or copy a SQL Server table so that it appears to be a system table?
  1. Goti Bandu

    Post:119

    Points:835
    Re: How can I create a SQL Server system table

    Use the following command change your table to system object. So it will then appear in System Objects.

           EXEC sys.sp_MS_marksystemobject _MigrationHistory

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: How can I create a SQL Server system table

    SELECT name = convert(char(30),o.name), rows, dpages,o.id, type
    FROM sysindexes i JOIN sysobjects o ON o.id = i.id
    WHERE o.id < 100 and (indid = 0 or indid =1)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!