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 |
|
solent
Starting Member
33 Posts |
Posted - 2006-01-03 : 12:53:31
|
| [CODE]ALTER PROCEDURE [dbo].[usp_Sel_ErrorRecord] @ERR_USERNAME varchar(200) = NULL,@ERR_NUMBER int = NULL,@ERR_PROCEDURE varchar(126) = NULL,@ERR_TIME datetime = NULL,@ErrorTime datetime OUTPUT,@UserName varchar(200) OUTPUT,@ErrorNumber int OUTPUT,@ErrorSeverity int OUTPUT,@ErrorState int OUTPUT,@ErrorProcedure varchar(126) OUTPUT,@ErrorLine int OUTPUT,@ErrorMessage varchar(4000) OUTPUTASBEGINSET NOCOUNT ON;SET @ERR_USERNAME = CONVERT(sysname, @ERR_USERNAME)SELECT @ErrorTime = ErrorTime, @UserName = UserName, @ErrorNumber = ErrorNumber, @ErrorSeverity = ErrorSeverity, @ErrorState = ErrorState, @ErrorProcedure = ErrorProcedure, @ErrorLine = ErrorLine, @ErrorMessage = ErrorMessageFROM ErrorLogWHERE UserName = @ERR_USERNAME AND ErrorNumber = @ERR_NUMBER AND ErrorProcedure = @ERR_PROCEDURE AND ErrorTime = @ERR_TIMEEND[/CODE]i have the above sproc and i want to retrive the following recordUsername: dboErrorNumber: 515ErrorProcedure: usp_Ins_UserErrorTime: 03/01/2006 17:48:31but it dosent work. if i remove the ErrorTime where clause it works but if not then the output params return NULL.apparently i need some sort of conversion on the @ERR_TIME parameters but i havent yet figured out which one to use.any ideas?Thanks |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-01-03 : 13:11:35
|
| You didn't provide enough info to say for sure but it's one of these:1. you are passing NULL as input for @err_Time2. you are passing a datetime value for @err_time that doesn't have an exact match (to the millisecond) to a value in ErrorLog.ErrorTimeBe One with the OptimizerTG |
 |
|
|
solent
Starting Member
33 Posts |
Posted - 2006-01-03 : 13:18:18
|
| thanks TG for the replybut i dont pass a null value and i pass the variable to @ERR_TIME to the exact match to the last milisecond. |
 |
|
|
solent
Starting Member
33 Posts |
Posted - 2006-01-03 : 13:21:07
|
| i am sure about the above because i pass the datetime variable from a c# asp.net and i debug and watch the varible from c# and it is indeed that one i posted above. could it be something else? |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-01-03 : 13:31:09
|
| the one you posted above doesn't not include milliseconds. What is the datatype of ErrorTime columns? Do a select from the table to see the value you're interested in. It might be a datetime/smalldatetime issue. check this out:select convert(smalldatetime, getdate()), getdate()--where convert(smalldatetime, getdate()) = getdate()uncomment the where clause and see what happens.Be One with the OptimizerTG |
 |
|
|
solent
Starting Member
33 Posts |
Posted - 2006-01-03 : 13:42:14
|
| i havent yet tested what you said but i just took a closer look at my application and i belive i dont inlucde the milleseconds.i will try what you said in a bit and see how it goes.thanks TG |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-01-03 : 13:47:40
|
I bet your table has errorTime as smallDateTime. It may be as simple as defining your parameter as smallDateTimedeclare @err_time datetimeset @err_time = '03/01/2006 17:48:31'select *from ( select convert(smallDatetime, '03/01/2006 17:48:31') sdt ,convert(Datetime, '03/01/2006 17:48:31') dt ) awhere sdt = @err_timegodeclare @err_time smalldatetimeset @err_time = '03/01/2006 17:48:31'select *from ( select convert(smallDatetime, '03/01/2006 17:48:31') sdt ,convert(Datetime, '03/01/2006 17:48:31') dt ) awhere sdt = @err_time Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|