Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

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



Application Security Testing: An Integral Part of DevOps

Insert Statement Problem

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*/
   INSERT INTO AdminUser 
      [Address 1],
      [Address 2],
      [Address 3],
      [Company Name],
      [Post Code].
      [Parent User ID],
      [Equivalant User ID]
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]

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 

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.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date