Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Script Question

Author  Topic 

viperbyte
Posting Yak Master

132 Posts

Posted - 2010-04-01 : 14:10:46
Hi everyone. I've taken on a vb project where I've been given a script that creates a number of tables. All the tables’ creations end with a "ON PRIMARY". There's no mention of PRIMARY KEY in the script on any of the create table part of the script. What does "ON PRIMARY" do in the script if a column isn't specified as the key? I have include one create table snippet in this message for example.

USE [develop]
GO
/****** Object: Table [develop_develop].[CMRC_Articles] Script Date: 02/22/2010 11:29:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[develop_develop].[CMRC_Articles]') AND type in (N'U'))
BEGIN
CREATE TABLE [develop_develop].[CMRC_Articles](
[ArticleID] [int] NOT NULL,
[Title] [nvarchar](50) NOT NULL,
[Description] [nvarchar](255) NOT NULL,
[Link] [nvarchar](250) NULL,
[Category] [nvarchar](20) NOT NULL,
[ArticleData] [varbinary](max) NOT NULL,
[DocType] [nvarchar](4) NOT NULL,
[ArticleDate] [datetime] NULL,
[Hide] [bit] NOT NULL
) ON [PRIMARY]
END

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-01 : 14:12:58
ON PRIMARY refers to creation of table in primary filegroup

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-01 : 14:15:39
see

http://www.sql-server-performance.com/articles/per/optimize_filegroup_performance_p1.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

viperbyte
Posting Yak Master

132 Posts

Posted - 2010-04-01 : 17:06:29
Thanks.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-01 : 17:12:54
If all you have is the PRIMARY filegroup, then that's where all objects reside. You can remove that part from your script without any issues.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

viperbyte
Posting Yak Master

132 Posts

Posted - 2010-04-01 : 18:21:32
What if i don't do anything at all in referance to a filegroup? I mean what if I don't explicitly code the size of it or where it resides or anything at all. Would it be ok to just leave it in the script? It's in the script so I imagine it's in there for a reason.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-01 : 18:25:52
The PRIMARY filegroup is the default one. It's there when you create a database.

Yes just leave it in the script. I've read some posts where people want to remove it from the scripts as they think it looks ugly. So you could do it either way.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -