Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > BOOK: Beginning VB.NET Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 23rd, 2006, 05:04 AM
Registered User
 
Join Date: May 2006
Location: , , Australia.
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
Reply With Quote
  #2 (permalink)  
Old May 23rd, 2006, 09:35 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Location: Fuquay Varina, NC, USA.
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
Reply With Quote
  #3 (permalink)  
Old May 25th, 2006, 04:52 AM
Registered User
 
Join Date: May 2006
Location: , , Australia.
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
Reply With Quote
  #4 (permalink)  
Old May 25th, 2006, 05:43 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Location: Fuquay Varina, NC, USA.
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
Reply With Quote
  #5 (permalink)  
Old April 24th, 2007, 11:48 AM
Registered User
 
Join Date: Apr 2007
Location: Fridley, MN, .
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.
Reply With Quote
  #6 (permalink)  
Old June 30th, 2007, 06:31 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nice information here.

Thanks

http://www.website-control.co.uk
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 06: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 05: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 12: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



All times are GMT -4. The time now is 05:31 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.