Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Scott Chang
Starting Member
1 Post |
Posted - 2007-12-16 : 15:22:06
|
| Hi all,I copied the following code from the article "Stored Procedure: Returning Data" written by Bill Graziano in this website:--sp_ReturnData.sql--USE AdventureWorksGOCREATE PROCEDURE dbo.GetPeopleByLastName (@LastName NVARCHAR(5))ASSELECT ContactID, FirstName, LastNameFROM Person.ContactWHERE LastName = @LastNameORDER By ContactIDGOEXEC dbo.GetPeopleByLastName @LastName = 'Alexander'GO=============================I executed the above code in my SQL Server Management Studio Express (SSMSE). It ran OK, but I got the following output:Message: no affected.Results: just the title "ConttactID", "FirstName", "LastName" printed and no output of @LastName = 'Alexander' at all. I am new in doing the Stored Procedure proframming and I do not know where I made a mistake in the sql script. Please help and advise me how to correct this problem and how to get the output printed out.Thank in advance,Scott Chang |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-12-16 : 15:52:10
|
| Run following in ssmse to see what you get:SELECT ContactID, FirstName, LastNameFROM Person.ContactWHERE LastName = 'Alexander' ORDER By ContactID |
 |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2007-12-16 : 15:52:25
|
| The @LastName parameter needs to be NVARCHAR(50). It's truncating the 'Alexander' down to 'Alexa'.=================================================Creating tomorrow's legacy systems today. One crisis at a time. |
 |
|
|
|
|
|