Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

on primary Expand / Collapse
Author
Message
Posted Monday, April 1, 2013 5:36 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Saturday, March 5, 2016 12:42 AM
Points: 83, Visits: 480
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
Post #1437405
Posted Monday, April 1, 2013 6:17 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, September 17, 2015 7:48 AM
Points: 1,002, Visits: 3,420
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
Post #1437413
Posted Monday, April 1, 2013 6:19 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:29 PM
Points: 14,189, Visits: 37,095
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!
Post #1437415
Posted Monday, April 1, 2013 6:32 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 1:54 PM
Points: 44,478, Visits: 42,084
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

Post #1437420
Posted Tuesday, April 2, 2013 6:01 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Saturday, November 28, 2015 7:06 AM
Points: 55, Visits: 328
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.


Post #1437850
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse