[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SQL 2005 Stored Procedure

Posted on 2008-06-17
4
Medium Priority
?
267 Views
Last Modified: 2010-03-19
I am getting the following error message:
Msg 102, Level 15, State 1, Procedure InsertRMR, Line 8
Incorrect syntax near 'nvarchar'.
Msg 137, Level 15, State 2, Procedure InsertRMR, Line 18
Must declare the scalar variable "@".
My Srored Procedure:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[InsertRMR]

@"site" nvarchar(50)=NULL,
@"date rec in PI" Datetime,
@"SS#" nvarchar(50)=NULL,
@"Description of Event" nvarchar(max),
@ "Originator" nvarchar,
@"date occured" Datetime,
@"date rec in PI" Datetime
As
Insert "dbo.RMR-FY08" ( "date rec in PI", site, "date occured", SS#, "description of event", originator)

Values ( @"date rec in PI", @"site", @"date occured", @"SS#", @"description of event", @originator)

Thanks for your help!





0
Comment
Question by:sandorka
[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
  • 2
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 21807174
you cannot use spaces in variables...
ALTER Procedure [dbo].[InsertRMR] 
@site nvarchar(50)=NULL, 
@date_rec_in_PI Datetime, 
@SS nvarchar(50)=NULL,
@Description_of_Event nvarchar(max), 
@Originator nvarchar(max),
@date_occured Datetime,
@date_rec_in_PI Datetime 
As 
Insert into [dbo].[RMR-FY08] ( [date rec in PI], site, [date occured], [SS#], [description of event], originator) 
Values ( @date_rec_in_PI, @site, @date_occured, @SS, @description_of_event, @originator)

Open in new window

0
 
LVL 14

Assisted Solution

by:PockyMaster
PockyMaster earned 1000 total points
ID: 21807467
even try to avoid spaces in columnNames as well. they're just annoying. (Also try to avoid underscores)

I prefer @dateRec instead. and e.g. DescriptionOfEvent for the column name.
Also try to avoid characters like #.
Use @SSNumber of something like that (probably SS means something as well..)

most of the time you want to SET NOCOUNT ON as well.

In Sql 2005 you have templates if you don't know what to do in some cases.

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21807490
<..>Also try to avoid underscores<...>
you make me curious about the "why" for avoiding underscores?
0
 
LVL 14

Expert Comment

by:PockyMaster
ID: 21807684
It has no performance reasons or whatsoever. It's a recommendation for .NET, it's easier to read, but of course, that's a matter of taste. Since lots of people generate code straight out of database schema's it will save you time stripping these underscores out and preventing CodeAnalysis warnings later.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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

650 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