Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Jun 12, 2000

Insert Statement Problem

Question:
I am facing a problem with the following SQL stored procedure:
CREATE PROCEDURE usp_CreateAdminUser
   /*Input Parameters  for the Create Admin User   */
   @FullName         varchar(100),
   @Telephone         varchar(50),
   @Email            varchar(50),
   @Address1         varchar(100),
   @Address2         varchar(100),
   @Address3         varchar(100),
   @City            varchar(50),
   @CompanyName      varchar(100),
   @State            varchar(50),
   @PostCode         varchar(50),
   @POBox         varchar(50),
   @Country         varchar(50),
   @LoginName         varchar(100),
   @Password         varchar(100),
   @ParentUserID         numeric(9),
   @EuivalantUserID      numeric(9),
   @AdminID         numeric(9)   OUTPUT      
   /*Output Parameter - Auto incremented Admin ID*/
AS
   INSERT INTO AdminUser 
      (
      [FullName],
      [Telephone],
      [Email],
      [Address 1],
      [Address 2],
      [Address 3],
      [City],
      [Company Name],
      [State],
      [Post Code].
      [POBox],
      [Country],
      [LoginName],
      [Password],
      [Parent User ID],
      [Equivalant User ID]
      ) 
   VALUES
      (
      @FullName,
      @Telephone,
      @Email,
      @Address1,
      @Address2,
      @Address3,
      @City,
      @CompanyName,
      @State,
      @PostCode,
      @POBox,
      @Country,
      @LoginName,
      @Password,
      @ParentUserId,
      @EuivalantUserID
      )
This is the error I get:
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
My table structure is in MS SQL 7:
if exists (select * from sysobjects where 
   id = object_id(N'[dbo].[AdminUsers]') 
   and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AdminUsers]
GO

CREATE TABLE [dbo].[AdminUsers] (
   [AdminID] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
   [FullName] [varchar] (100) NOT NULL ,
   [Telephone] [varchar] (50) NULL ,
   [Email] [varchar] (50) NOT NULL ,
   [Address 1] [varchar] (100) NULL ,
   [Address 2] [varchar] (50) NULL ,
   [Address 3] [varchar] (50) NULL ,
   [City] [varchar] (50) NOT NULL ,
   [Compnay Name] [varchar] (100) NOT NULL ,
   [State] [varchar] (50) NULL ,
   [Post Code] [varchar] (50) NULL ,
   [POBOX] [varchar] (50) NULL ,
   [Country] [varchar] (50) NOT NULL ,
   [LoginName] [varchar] (100) NOT NULL ,
   [Password] [varchar] (100) NOT NULL ,
   [Parent User ID] [numeric](18, 0) NULL ,
   [Equivalant User ID] [numeric](18, 0) NULL ,
   [Status] [int] NULL 
) ON [PRIMARY]
GO

Answer:
The problem seems to be a period instead of a comma in your query values list right after the [Post Code] column. If you change this:

[Post Code].
to this:
[Post Code],
it'll work fine.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date