Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 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 February 23rd, 2009, 12:15 PM
Registered User
 
Join Date: Feb 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Unhappy Error Msg 128, Level 15, State 1

Just created a new tabel/database. The table is
Category
Cat_id(char(2)not null)
CatName(char(25),null)

Inset statement:
Code:
insertinto Category (Cat_id,CatName)
values("01","Dance-Ballet");


Error message:
Msg 128, Level 15, State 1, Line 2
The name "Dance-Ballet" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

What am I missing? And how do I fix ASAP!
Thanks for the help.

 
Old February 23rd, 2009, 12:38 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Try INSERT INTO Category (Cat_id, CatName) VALUES ('01', 'Dance-Ballet')

Are you trying to create an identity column for Cat_id? If so, you would never have to insert a value since SQL will create a new identity for every insertion.

Just make Cat_id into an identity column.

Hope this helps.

Richard
 
Old February 23rd, 2009, 12:58 PM
Registered User
 
Join Date: Feb 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

how do I make this an identity column in SQL Manager? I understand that it is not necessary to insert a value in the Cat_id column. I tried the code
(NSERTINTO Category (Cat_id, CatName)VALUES('01','Dance-Ballet');)
and get the error:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'Category'.


I can't find a way to upload a screen print...

Any other ideas?
Thanks
 
Old February 23rd, 2009, 02:08 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

The syntax is INSERT [space] INTO

You also need spaces on either side of VALUES

Try this:

SELECT * FROM Category

Let me know what results you get.

You need to modify the table. What version of SQL are you using?
 
Old February 23rd, 2009, 02:33 PM
Registered User
 
Join Date: Feb 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

resluts from " Select * from Category"

Msg 208, Level 16, State 1, Line 1
Invalid object name 'Category'.

Am using SQLEXPRESS (SQL Server 9.0.1399...)
 
Old February 23rd, 2009, 07:29 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Looks like you don't have any table named Category in that database.

Not sure why, since you say you created the table.

Did you try looking at the DB with SQL Server Management Studio? There should be a free Express edition you can use.
The Following User Says Thank You to Old Pedant For This Useful Post:
paulw4 (February 24th, 2009)
 
Old February 24th, 2009, 10:35 AM
Registered User
 
Join Date: Feb 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Lets close this, I have had to move to a different method, since this was not working...too much time for something that should be simple.
Thanks for all the help.
 
Old February 25th, 2009, 04:51 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You have another schema than dbo?





Similar Threads
Thread Thread Starter Forum Replies Last Post
error msg almotions ASP.NET 2.0 Basics 3 February 12th, 2008 08:34 AM
Server: Msg 128, Level 15, State 1, Line 3 amit.jagtap SQL Server 2005 1 August 9th, 2007 08:50 AM
error msg aspsuraj BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 November 27th, 2006 08:30 PM
p.128 ch.4 createreviews.php ERROR wildroosta BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 September 12th, 2004 09:17 AM
Breakpoint Error Msg Louisa VB.NET 2002/2003 Basics 1 March 29th, 2004 06:42 AM





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