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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Whats wrong with my insert statement

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2006-12-22 : 13:45:41
Trying to use the following statement to insert some data.
It is giving the following error

Server: Msg 128, Level 15, State 1, Line 3
The name '#12' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.

Whats wrong. thanks


INSERT INTO extension
(ext_due_evals_id,ext_empid,ext_updated_by,ext_hist_todate)
VALUES ('399999','505592','919999','12/14/20061')


CREATE TABLE [extension] (
[extid] [int] IDENTITY (1, 1) NOT NULL ,
[ext_due_evals_id] [int] NULL ,
[ext_empid] [datetime] NULL ,
[ext_updated_by] [datetime] NULL ,
[ext_updated_date] [datetime] NULL ,
[ext_hist_todate] [datetime] NULL ,
CONSTRAINT [PK_extension] PRIMARY KEY CLUSTERED
(
[extid]
) ON [PRIMARY]
) ON [PRIMARY]
GO

cognos79
Posting Yak Master

241 Posts

Posted - 2006-12-22 : 13:50:45
ext_due_evals_id is integer and so you dont need quotes around tht value.
also ext_empid and ext_update_by are datetime datatypes...check those values again.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-22 : 14:06:48
Even then the error message which he is getting should be different like,

"Syntax error converting datetime from character string."

I think you are looking at wrong statement or not posting statement in exactly same way it is there.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-12-22 : 14:12:52
quote:

INSERT INTO extension
(ext_due_evals_id,ext_empid,ext_updated_by,ext_hist_todate)
VALUES ('399999','505592','919999','12/14/20061')


CREATE TABLE [extension] (
[extid] [int] IDENTITY (1, 1) NOT NULL ,
[ext_due_evals_id] [int] NULL ,
[ext_empid] [datetime] NULL ,
[ext_updated_by] [datetime] NULL ,
[ext_updated_date] [datetime] NULL ,
[ext_hist_todate] [datetime] NULL ,
CONSTRAINT [PK_extension] PRIMARY KEY CLUSTERED
(
[extid]
) ON [PRIMARY]
) ON [PRIMARY]
GO



- Jeff
Go to Top of Page

csphard
Posting Yak Master

113 Posts

Posted - 2006-12-22 : 14:15:53
I am sorry 20061 was an error. I am using 2006 and it is giving me the same error.

Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2006-12-22 : 15:49:02
quote:


INSERT INTO extension
(ext_due_evals_id,ext_empid,ext_updated_by,ext_hist_todate)
VALUES ('399999','505592','919999','12/14/20061')


CREATE TABLE [extension] (
[extid] [int] IDENTITY (1, 1) NOT NULL ,
[ext_due_evals_id] [int] NULL ,
[ext_empid] [datetime] NULL ,
[ext_updated_by] [datetime] NULL ,
[ext_updated_date] [datetime] NULL ,
[ext_hist_todate] [datetime] NULL ,
CONSTRAINT [PK_extension] PRIMARY KEY CLUSTERED
(
[extid]
) ON [PRIMARY]
) ON [PRIMARY]
GO




If you'll note, you're putting a varchar value into an int column, and another two invalid varchar value values into a two datetime columns. You should probably fix those errors and see if the problem goes away.

Ken
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-22 : 23:12:40
quote:
Originally posted by csphard

I am sorry 20061 was an error. I am using 2006 and it is giving me the same error.




Did you note what Jeff pointed out?

It is strange that ext_empid has DATETIME datatype. Either change column name or datatype accourdingly

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -