Wrox Programmer Forums
|
BOOK: Beginning VB.NET Databases
This is the forum to discuss the Wrox book Beginning VB.NET Databases by Thearon Willis; ISBN: 9780764568008
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 23rd, 2006, 05:04 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 1: SQL script syntax

Rather than build the SQL database by hand, I'm attempting to run the SQL script. My issue is that I'm receiving several syntax errors of the form below:

Server: Msg 156, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'PRIMARY'.

The line of code in the sql which causes the above error is marked in red below:

---------------------------------------------------------------------
-- Primary Keys
---------------------------------------------------------------------
ALTER TABLE GroupProjects WITH NOCHECK ADD
    CONSTRAINT PK_GroupProjects PRIMARY KEY CLUSTERED
    (
        GroupProjectID
    ) ON PRIMARY
GO

----------

Can anyone offer any advice? I've not used sql scripts much before - and google could not help.

I'm using SQL Server Version 8.00.760.

Thanks,
Greg
 
Old May 23rd, 2006, 09:35 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Greg,

You can remove the keywords "ON PRIMARY" and your scripts should run just fine.

Thearon
 
Old May 25th, 2006, 04:52 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Thearon,
That worked - could you explain (for my benefit) why I need to remove that syntax on my system - is it a version issue?
Regards
Greg
 
Old May 25th, 2006, 05:43 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Greg,

After creating the tables, I let SQL Server generate the script. I have noticed, using SQL Server 2000, that sometimes this causes an error. I believe it may have something to do with how SQL Server is installed (e.g. options selected). However I have not really had the time to dig into the problem deeper.

Thearon
 
Old April 24th, 2007, 11:48 AM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

PRIMARY is the name of your filegroup. You can also use DEFAULT. The problem that you're seeing is that both PRIMARY and DEFAULT are already SQL keywords. Replace PRIMARY with [PRIMARY] and all of your scripts will work fine.

I suspect that you used the scripting tool to generate your SQL but then did a search/replace to knock off the [s and ]s, causing your problem.
 
Old June 30th, 2007, 06:31 AM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nice information here.

Thanks

http://www.website-control.co.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
How Run .sql Script file in MS SQL Server 2000? aarkaycee SQL Server 2000 5 October 12th, 2009 05:43 AM
chapter 6: scaffold syntax error cwhite124 BOOK: Beginning Ruby on Rails 1 January 3rd, 2008 07:20 AM
SQL syntax error - Chapter 3 cutthroatchemist BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 January 15th, 2007 06:19 PM
Chapter 12 Web Method syntax VictorVictor BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 February 23rd, 2006 01:46 PM
chapter 6, page 173-175, error in sql syntax vkranendonk BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 May 26th, 2004 12:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.