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 |
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2008-09-16 : 11:26:56
|
| Hello,I have a SP that returns a variable of varchar(30)asset @password = 'wait'return @passwordI get this error below.Why ?Msg 245, Level 16, State 1, Procedure mybilling, Line 107Conversion failed when converting the varchar value 'wait' to data type int._____________________Yes O ! |
|
|
jordanam
Yak Posting Veteran
62 Posts |
Posted - 2008-09-16 : 11:34:55
|
| Do you get the error compiling the proc or running it?If it's a compile error, then my guess (and seeing the code would identify this quickly) is that you are performing a calculation using the variable or that there is a typo. If it's a run error, then it depends on how you're calling the sproc.Posting code would help.-------------if your code was posted in this post: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=110730then you are trying to set the password variable to a number (charindex is a numeric value). You can cast/convert that.On charindex from BOL:http://msdn.microsoft.com/en-us/library/ms186323.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-16 : 11:51:23
|
quote: Originally posted by mary_itohan Hello,I have a SP that returns a variable of varchar(30)asset @password = 'wait'return @passwordI get this error below.Why ?Msg 245, Level 16, State 1, Procedure mybilling, Line 107Conversion failed when converting the varchar value 'wait' to data type int._____________________Yes O !
whats the datatype of @password?Also if you're doing this in udf whats the return type of udf? |
 |
|
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2008-09-16 : 13:04:18
|
| declare @password varchar(30)set @password = 'wait'return @password_____________________Yes O ! |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2008-09-16 : 14:23:15
|
Use a output variableCreate proc GetMyVal@Password varchar(30) outputasSelect @Password = 'wait'godeclare @PW varchar(30)exec GetMyVal @Password = @PW outputselect @PWgodrop proc GetMyVal Success is 10% Intelligence, 70% Determination, and 22% Stupidity.\_/ _/ _/\_/ _/\_/ _/ _/- 881 |
 |
|
|
|
|
|
|
|