Solved

INSERT statement syntax in SQL Server 2008

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CDC and AOG on MS SQL 2012 13 23
SQL query and VBA 5 45
What is the best way to use power bi and ssrs 3 23
MS SQL Delete Duplicate Rows Only 2 15
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.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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.

808 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