Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server Newbies
»
Create Procedure paramaters
Create Procedure paramaters
Rate Topic
Display Mode
Topic Options
Author
Message
mark-1113653
mark-1113653
Posted Saturday, June 13, 2009 10:39 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 5:22 AM
Points: 2,
Visits: 7
Good morning everyone.
I am attempting to complete some basic SQL training and I continue to receive the following error when attempting to create a procedure with a variable.
"Msg 207, Level 16, State 1, Procedure GET_CD_ARTISTS, Line 8 Invalid column name 'p_CD'
The code I am using is below this line:
CREATE PROCEDURE GET_CD_ARTISTS (@p_CD VARCHAR(60))
AS
SELECT cd.CD_TITLE, a.ARTIST_NAME
FROM COMPACT_DISCS cd, ARTIST_CDS ac, ARTISTS a
WHERE cd.COMPACT_DISC_ID = ac.COMPACT_DISC_ID
AND ac.ARTIST_ID = a.ARTIST_ID
AND cd.CD_TITLE = p_CD;
I just can't figure out where the variable is causing an invalid column error.
Thank you in advance for the help.
Post #734366
ALZDBA
ALZDBA
Posted Saturday, June 13, 2009 10:47 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 7:03 AM
Points: 6,861,
Visits: 8,048
mark (6/13/2009)
Good morning everyone.
I am attempting to complete some basic SQL training and I continue to receive the following error when attempting to create a procedure with a variable.
"Msg 207, Level 16, State 1, Procedure GET_CD_ARTISTS, Line 8 Invalid column name 'p_CD'
The code I am using is below this line:
CREATE PROCEDURE GET_CD_ARTISTS (@p_CD VARCHAR(60))
AS
SELECT cd.CD_TITLE, a.ARTIST_NAME
FROM COMPACT_DISCS cd, ARTIST_CDS ac, ARTISTS a
WHERE cd.COMPACT_DISC_ID = ac.COMPACT_DISC_ID
AND ac.ARTIST_ID = a.ARTIST_ID
AND cd.CD_TITLE = p_CD;
I just can't figure out where the variable is causing an invalid column error.
Thank you in advance for the help.
We all often forget the @ when typing a proc in a hurry.
Enclose your sproc code in a BEGIN / END sequence.
This is meerly for completeness check of your proc at implement time.
And use the "set nocount on " to avoid unneeded network trafic
btw also start using the JOIN syntax for joining objects.
CREATE PROCEDURE GET_CD_ARTISTS (@p_CD VARCHAR(60))
AS
BEGIN
SET NOCOUNT ON ;
SELECT cd.CD_TITLE, a.ARTIST_NAME
FROM COMPACT_DISCS cd
INNER JOIN ARTIST_CDS ac
on ac.COMPACT_DISC_ID = cd.COMPACT_DISC_ID
INNER JOIN ARTISTS a
on a.ARTIST_ID = ac.ARTIST_ID
Where cd.CD_TITLE =
@p_CD;
END
Johan
Jul 13
Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere
-
How to post Performance Problems
-
How to post data/code to get the best help
-
How to prevent a sore throat after hours of presenting ppt ?
"press F1 for solution", "press
shift
+F1 for urgent solution"
Need a bit of Powershell? How about
this
Who am I ?
Sometimes this is me
but
most of the time this is me
Post #734369
mark-1113653
mark-1113653
Posted Saturday, June 13, 2009 10:53 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 5:22 AM
Points: 2,
Visits: 7
LOL Thank you. I can hardly believe it is a simple as an incorrect name reference. I thought the @ symbol was only a part of the designation and not the name.
Post #734371
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.