SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Conversion problem


Conversion problem

Author
Message
Dannie
Dannie
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 72
Hi,

I have a SP to return a datetime value. However, when I EXECUTE the SP I always get this error

[color=#FF0000]Msg 257, Level 16, State 3, Procedure sp_date_after_clarify_close, Line 57
Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.[/color]

Here is the complete code.

Thanks!


----------------------------------------------------------------
Main Program


DECLARE @date_after_clarify_close datetime

EXEC @date_after_clarify_close=dbo.sp_date_after_clarify_close
@date_clarify_close,
@int_issue_id,
''


-----------------------------------------------------------------

STORED PROCEDURE


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[sp_date_after_clarify_close]
@date_clarify_close datetime,
@int_issue_id int,
@date_after_clarify_close datetime OUTPUT
AS
BEGIN
SET NOCOUNT ON;

DECLARE @date_temp datetime

DECLARE cr_date_after_clarify_close CURSOR
FOR
SELECT date_response
FROM responses
WHERE issue_id = @int_issue_id
ORDER BY date_response

OPEN cr_date_after_clarify_close

FETCH NEXT FROM cr_date_after_clarify_close into @date_temp

WHILE @@FETCH_STATUS = 0
BEGIN

IF @date_temp = @date_clarify_close
BEGIN
FETCH NEXT FROM cr_date_after_clarify_close into @date_temp

SET @date_after_clarify_close = @date_temp
END
ELSE
FETCH NEXT FROM cr_date_after_clarify_close into @date_temp

END

CLOSE cr_date_after_clarify_close

DEALLOCATE cr_date_after_clarify_close

RETURN (@date_after_clarify_close) --> If I remark this RETURN then it's working fine.

END

--------------------------------------------------------------------
ALZDBA
ALZDBA
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30807 Visits: 8986
Check RETURN in bol !
Return is not used to fillup output variables, but it gives an integer value to the calling object. (mostly used to indicate OK or not OK)

To fill up the output variable, just use a set or select statement !

in your case, just use RETURN without anything else at that place

Johan


Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere w00t

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


press F1 for solution, press shift+F1 for urgent solution :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search