?
Solved

INSERT statement syntax in SQL Server 2008

Posted on 2013-05-12
3
Medium Priority
?
512 Views
Last Modified: 2013-05-12
I am new to SQL coding and am trying to get an INSERT Statement using parameters to work.  I get two errors here when trying to create this procedure.  Both seem to revolve around the date parameter.  

CREATE PROCEDURE spAddAssetInventory
      -- Add the parameters for the stored procedure here
      @AssetName nchar
      @AssetDate datetime
      @AssetFlag nchar  
      @AssetID int      
AS
BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;

    -- Insert statements for procedure here
      INSERT INTO  dbo.tbl_AssetInventory(AssetID, AssetName, AssetInServiceDate, AssetInventoryActiveFlag)
      VALUES     (@AssetID,@AssetName,@AssetDate,@AssetFlag)
END
GO
0
Comment
Question by:marku24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 39159495
It would really help if you can post the error messages you're getting. Also, what are the datatypes of your table columns?
0
 
LVL 12

Accepted Solution

by:
HugoHiasl earned 1000 total points
ID: 39159637
1. You need to separate the parameters by comma.

2. You should change your nchar parameters to use a lenght like nchar(50) except you plan it to be 1 character in length.

It seem to be caused by the DateTime parameter because this is the first unexpected content when you missed the comma as separator.
0
 

Author Closing Comment

by:marku24
ID: 39160064
that was it exactly, thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question