Solved

INSERT statement syntax in SQL Server 2008

Posted on 2013-05-12
3
480 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
3 Comments
 
LVL 12

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 250 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now