on primary

  • why on primary is used while creating a table is it necessary

    ex:

    create table temp

    (name varchar(50),age smallint,salary int)on primary

  • Because that you can have more than one filegroup. And that tells SQL Server to create the object in a certain file group. Yes, it is required. That is, I have always typed it. You can look in the SQL BOL to be sure.

    Andrew SQLDBA

  • AndrewSQLDBA (4/1/2013)


    Because that you can have more than one filegroup. And that tells SQL Server to create the object in a certain file group. Yes, it is required. That is, I have always typed it. You can look in the SQL BOL to be sure.

    Andrew SQLDBA

    technically it's not required as far as the CREATE TABLE command goes, but if you leave it off, it gets created on the PRIMARY file group anyway, because that is the default group.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • It's not required. Leave it off and the table or index gets created in the default filegroup. That's Primary by default, but can be changed

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Get into a habit of leaving the "on primary" off all your code. When the code gets released the DBA can decide if it is appropriate where the objects (tables, indexes) are supposed to be by defining which filegroup is the default. In general its the DBA and not the developer who is responsible for the file & object placement on the system and in an agile environment under pressure you try getting 20 developers environments to accept multiple file groups!

    To turn the auto scripting of then is SSMS

    Menu->Tools -> options-> Sql Server Object Explorer->Scripting

    scroll down to "Table and view options" then find "Script File Groups" and set the option to false.

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

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