Hello,
I am writing a function in transact-sql for sql server 2005. I am trying to cast an sql_variant value to datetime. This generates an error. I would appreciate any syntax advice you can give.
Thanks alot!
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[holiday]
( @fDate1 sql_variant )
RETURNS tinyint
AS
BEGIN
DECLARE @myInt tinyInt;
declare @fDate2 datetime;
@fDate2= cast(@fDate1 as datetime);
SET @myInt = 0;
if exists(select * from dbo.holidayTable where observanceDate=@fDate2)
begin
set @myInt=1
end
RETURN @myInt
END
I am writing a function in transact-sql for sql server 2005. I am trying to cast an sql_variant value to datetime. This generates an error. I would appreciate any syntax advice you can give.
Thanks alot!
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[holiday]
( @fDate1 sql_variant )
RETURNS tinyint
AS
BEGIN
DECLARE @myInt tinyInt;
declare @fDate2 datetime;
@fDate2= cast(@fDate1 as datetime);
SET @myInt = 0;
if exists(select * from dbo.holidayTable where observanceDate=@fDate2)
begin
set @myInt=1
end
RETURN @myInt
END