Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 6th, 2005, 09:34 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default syntax problem with SQL

Hi I'm VERY new to SQL and am having trouble with its syntax.
Brief: I need to add columns to my table that will be named TITLE, DESCRIPTION KEYWORDS ...that simple!

Here's my code:

ALTER TABLE Products ADD COLUMN description TITLE


Here's the error message:

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


AS always Your help is greatly appreciated,
Thanks

nancy
 
Old May 6th, 2005, 09:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

If its the basic syntax you're stuck with you could just look it up in Books On Line.

w3schools always have good basic tutorials:
http://www.w3schools.com/sql/

Your statement doesn't need the COLUMN keyword to add a column (but you do need it to drop a column!), and you also need to specify the data type of the new field. Plus you need one ALTER statement for each new column.
 
Old May 6th, 2005, 09:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sorry I'm wrong, you don't need one ALTER statement per column, you can separate multiple columns by a ,
 
Old May 6th, 2005, 12:45 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You can also add the column(s) through enterpise manager.

 
Old May 6th, 2005, 12:56 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To all,Thank you very much.
It was indeed a syntax error that is now resolved.

Nancy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with SQL syntax DeannaF829 VB Databases Basics 2 April 30th, 2007 12:12 PM
SQL-syntax grstad SQL Language 9 January 30th, 2007 02:40 PM
SQL Syntax Cinderella Classic ASP Basics 3 July 21st, 2004 01:06 PM
SQL Syntax jeffg22 SQL Language 6 July 28th, 2003 06:41 PM
sql server syntax problem mateenmohd SQL Server 2000 3 June 23rd, 2003 07:31 PM





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