Solved

INSERT statement syntax in SQL Server 2008

Posted on 2013-05-12
3
505 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 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

690 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