Francisco Tapia
fhtapia at gmail.com
Fri Jan 14 10:13:01 CST 2005
No, you can write either a subquery or a user defined function in
order to get the same functionality. here is an example of a text
returning function, the following function gives the diffrence between
two datetime entries yielding days, hours and minutes in the
difference.
CREATE FUNCTION udfDiffBetweenDates(
@StartDT DATETIME,
@EndDT DATETIME)
RETURNS VARCHAR(30)
AS
BEGIN
DECLARE @intMin Int,
@intHrs Int,
@intDys Int,
@TotalMin Int,
@strOUTPUT Varchar(30)
SET @TotalMin = ABS(DATEDIFF(mi, @StartDT, @EndDT))
SET @intDys = @TotalMin / (24*60)
SET @intHrs = (@TotalMin-(@intDys*24*60)) / 60
SET @intMin = @TotalMin-((@intDys*24*60)+(@intHrs*60))
If @StartDT <= @EndDT
Begin
SET @strOUTPUT = CAST(@intDys as varchar(5)) + 'Days, ' +
CAST(@intHrs as varchar(2)) + 'Hours, ' + cast( @intMin as
varchar(2)) + 'Minutes'
End
Else
Begin
SET @strOUTPUT = '-(' + cast( @intDys as varchar(5)) + 'Days, ' +
cast( @intHrs as varchar(2)) + 'Hours, ' + cast( @intMin as
varchar(2)) + 'Minutes' + ')'
End
RETURN @strOUTPUT
END
On Fri, 14 Jan 2005 11:20:25 +0100 (CET), paul.hartland at fsmail.net
<paul.hartland at fsmail.net> wrote:
> To all,
>
> Can anyone tell me if there is a SQL Server function that is equivalent to the Microsoft Access DLookUp function ?
>
> Thanks in advance for any help
>
> Paul Hartland
>
> --
>
> Whatever you Wanadoo:
> http://www.wanadoo.co.uk/time/
>
> This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>
--
-Francisco
http://pcthis.blogspot.com | PC news with out the jargon!