Click here to Skip to main content
15,903,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I recently tried some sample code from a SQL Share video and being new to T-SQL I have a question I hope someone will answer.

Here is the code sample:

SQL
create table test.Contact
(
	ContactID int identity not for replication not null,
	Title nvarchar(8) null,
	FirstName nvarchar(50) not null,
	MiddleName nvarchar(50) null,
	LastName nvarchar(50) not null,
	Suffix nvarchar(10) null,
	EmailAddress nvarchar(50) not null,
	Phone nvarchar(25) null,
	AddressLine1 nvarchar(60) not null,
	AddressLine2 nvarchar(60) not null,
	City nvarchar(30) not null,
	StateProvinceID int not null,
	PostalCode nvarchar(15) not null,
	constraint PK_Contact_ContactID 
	primary key clustered (ContactID asc)
	with 
	(
		pad_index = off,
		statistics_norecompute = off,
		ignore_dup_key = off,
		allow_row_locks = off
	)
) on [primary];
go


My question is why are the brackets needed around the "primary" keyword at the end of the statement?

I know of a couple case where brackets would be necessary such as keywords (I thought this may be why) but primary is being used as a keyword and not as an object name so I drew a blank.

Thanks in advance.
Posted
Updated 9-May-11 9:50am
v2
Comments
Dalek Dave 9-May-11 15:50pm    
Edited for Readability.

Because it's required to make it work. That's the best I know to tell you.
 
Share this answer
 
v2
Comments
Keith.Badeau 9-May-11 17:04pm    
Thank you sir, you are very correct. I had to watch the video and examine the code against the script I was trying to execute for differences.
Because PRIMARY is a keyword and in this case PRIMARY is the name of the filegroup.
 
Share this answer
 
v2
Comments
Keith.Badeau 9-May-11 17:01pm    
Thank you, this simple explanation was hard to come by in a google, MSDN, and BOL search.

I thought that using PRIMARY in this context it was still considered a keyword. Thanks again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900