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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Procedure help with date

Author  Topic 

reacha
Starting Member

49 Posts

Posted - 2010-10-07 : 14:19:28
When i run the below procedure i am getting the following error message

Msg 257, Level 16, State 3, Procedure get_AuditCompleted, Line 7
Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.


create procedure get_AuditCompleted(@pkgid int,@AuditCompleted datetime output)
as

set @AuditCompleted = (select Auditstamp from audit
where AUDIT.AUDITMSG = 'completed by user'
and AUDIT.PKGID =@pkgid)
return @AuditCompleted


Please help me out!!

Thanks,
reacha

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-07 : 14:30:35
You can not use RETURN with a datetime.

Just remove the RETURN. You've already set the variable and have defined it as output, so you are good.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-07 : 14:31:01
To be more clear, here you go:

create procedure get_AuditCompleted(@pkgid int,@AuditCompleted datetime output)
as

set @AuditCompleted = (select Auditstamp from audit
where AUDIT.AUDITMSG = 'completed by user'
and AUDIT.PKGID =@pkgid)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

reacha
Starting Member

49 Posts

Posted - 2010-10-07 : 14:33:37
Mrs. Tara Lyn Kizer

Thank you!! it worked
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-07 : 14:44:40
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -