|
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]
|