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 |
ganatra.neha
Starting Member
30 Posts |
Posted - 2007-10-27 : 21:39:24
|
Please let me know where my code is wrong.Stored Procedure gets created but does not work when try to executeThere is table called Production.ProductReviewThe columns are ProductReviewId, ProductId , Ratings and CommentsThere are only 4 rows in the table.The task is to write a stored procedure with input parameter as Product Review Id andOutput parameter as ProductId , Ratings and CommentsMy code is as followsUse AdventureWorksGoCreate Procedure dbo.ProductReview1 @ReviewId int,@ProductId int output,@Rating int output,@comments nvarchar outputAs Select @ReviewId = Pr.ProductReviewID from Production.ProductReview as PrSelect @ProductId =Pr.ProductID from Production.ProductReview as PrSelect @Rating = Pr.Rating from Production.ProductReview as PrSelect @Comments =Pr.Comments from Production.ProductReview as PrDeclare @ProductId int ,@Rating int ,@comments nvarchar Execute ProductReview1 2 @ProductId, @Rating,@CommentPrint @ProductId, @Rating,@Comment |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2007-10-27 : 21:52:22
|
homework question?you need to combine all of your output assignments into one select statement, and get rid of that stuff at the bottomselect @outParam1 = xxx, @outParam2 = yyyfrom yourTablewhere zzz = @inputParametc... |
 |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2007-10-27 : 22:59:31
|
Select @ProductId = productid, @Rating = rating, @Comments = @commentsfrom Production.ProductReviewwhere ProductReviewID = @ReviewId |
 |
|
ganatra.neha
Starting Member
30 Posts |
Posted - 2007-10-28 : 01:11:45
|
hank you so muchOnly one issue.When i type following code only 1st letter is dispalyed in comments columnDeclare @ProductId int , @Rating int, @comments varchar(3850)Execute ProductReview1 1, @ProductId output , @Rating output, @comments output Print @ProductId Print @Rating Print @comments |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-10-28 : 02:38:15
|
In your Sproc you have defined @comments with no size, the default is one character.Kristen |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-29 : 03:16:53
|
quote: Originally posted by Kristen In your Sproc you have defined @comments with no size, the default is one character.Kristen
As usual I expect it to return error saying "Column length is not specified" than debugging where it goes wrong. I still dont unserstand the advantage of implicitely converting to size 1MadhivananFailing to plan is Planning to fail |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-10-29 : 05:07:59
|
"I still dont unserstand the advantage of implicitely converting to size 1"Design / bug issue way back that is allowed to remain. 100% daft. All it needs is some backward-compatibility flags in the DB that are, for new databases, off by default.Even old timers like you and I can fall into this huge hole and waste time tracking down the cause. It happens with the newbies here, and I'm never looking in the right place to spot the cause because I just don't code without a size on char/varchar/etc.Don't you have an MVP hotline you can call, and complain, Madhi? Kristen |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-10-29 : 05:12:48
|
The OP has deleted one of their posts, it does annoy when people do that In fact checking their account the OPs post count is 9 but I can only see 6 posts. Might be 2 posts made in error, but the one deleted wasn't (from memory it was thanking me for helping with the Size parameter, and saying that 1000 or 4000 or somesuch has been used and the result was successful)Unless Snitz has taken a nose-diveKristen |
 |
|
|
|
|
|
|