Reply to Re: Stored procedure returns no value

Your name:

Reply:


Posted by Niels Berglund on 03/01/06 12:20

nikolacace@gmail.com wrote in
news:1141207756.690974.176180@v46g2000cwv.googlegroups.com:

> I have a stored procedure (the code is below) that I use to retrieve
> one value from my database. I tested the code in Query Analyzer, and
> it works (I get the value I was looking for). However, when I call the
> same code from the stored procedure, I get no value. The code that is
> executed is the same and the input parameter is the same. Does anybody
> have an idea?
>
> The code:
>
> SELECT Top 1
> CharID,
> CharName,
> CategoryName,
> CharDescription,
> UserID
> FROM [Character]
> WHERE CharName='Character'
>
> -- returns the right value
>
> The Stored Procedure:
>
> CREATE PROCEDURE SpCharacters_SelectOneByUserName
> @UserName NVarChar
> AS
> SELECT Top 1
> CharID,
> CharName,
> CategoryName,
> CharDescription,
> UserID
> FROM Character
> WHERE CharName=@UserName
> GO
>
> -- returns no value
>

The @UserName param in your stored procedure defaults to 1 character the
way you have defined it. You need to give it a size in the declaration:

CREATE PROCEDURE SpCharacters_SelectOneByUserName
@UserName NVarChar(50)

Niels


--
**************************************************
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb@no-spam.develop.com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
**************************************************

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация