Jump to content

Not accepting values


SqlBeginner

Recommended Posts

I'm needing to insert values into a table. I have the data type set up as varchar(4). The values are combinations of 4 letters and/or numbers. When trying to insert it won't accepts the alpha characters. The column is set to Not Null and as the primary key. Any suggestions as to why it won't accept?

Edited by SqlBeginner
Link to comment
Share on other sites

This is an example of how I'm putting it in

INSERT INTO [dbo].[tbljobs] (jobcode, Title) VALUES

(2834, 'Clinical Services Director'),(H27A, 'Clinical Social Worker'),(H27C, 'Clinical Social Worker'),(H27D, 'Clinical Social Worker')

 

When I put it into SQL it'll have red lines underneath it and I'll get the error Msg 207, level 16, state 1, line 1 Invalid column name

Link to comment
Share on other sites

Looking at the same table when I attempt to insert the values I'm receiving a new error message.

Msg 2627, Level 14, State 1, Line 1

Violation of PRIMARY KEY constraint 'PK_tblJobs'. Cannot insert duplicate key in object 'dbo.tblJobs'.

The statement has been terminated.

 

I went through all fields to ensure that there weren't any duplicate values but it still won't take it. JobID is the pk nvarchar(4) I also went through the 'title' column and changed any names that were the same.

Link to comment
Share on other sites

That means you're trying to insert a row with a value in the primary key that already exists in a row in the table. A primary key needs to be unique, you can't have multiple rows with the same value in that field.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...