Viewing 11 posts - 1 through 11 (of 11 total)
And as everybody knows, the best tricks involve pyrotechnics! I say points for everybody except those stocking-stuffers!
October 31, 2008 at 1:25 pm
The best function to use for calculating age is:
DATEDIFF(yy, @DateOfBirth, GETDATE()) -
CASE WHEN (DATEPART(m, @DateOfBirth) > DATEPART(m, GETDATE()))
OR(DATEPART(m, @DateOfBirth) = DATEPART(m, GETDATE())
AND DATEPART(d, @DateOfBirth) > DATEPART(d,...
March 6, 2008 at 7:14 pm
It does appear that the default settings for databases in SQL 2005 do have the ANSI_NULLS values set to OFF. But the reverse seems to be the case for queries...
February 25, 2008 at 2:47 pm
This a perfect scenario for a case statement.
Select case when AddressHome = "" then AddressPO
else AddressHome end as Address
from table
This assumes the...
February 13, 2008 at 6:32 pm
If you do go with passing the table name in and using dynamic SQL in your queries, it is suggested that you first validate the text that came in before...
February 6, 2008 at 7:09 pm
First, use the dateadd function instead of trying to subtract an integer from a date (i.e. use dateadd(day, -2, getdate()) instead of getdate()-2) to make sure that the parameter you're...
February 6, 2008 at 6:27 pm
DECLARE @Sequence TABLE
(
Modulo INT,
Value INT
)
INSERT INTO @Sequence
(Modulo,Value)
SELECT 0,1 UNION ALL
SELECT 1,1 UNION ALL
SELECT 2,2 UNION ALL
SELECT 3,2 UNION ALL
SELECT 4,3 UNION ALL
SELECT 5,3 UNION ALL...
December 3, 2007 at 2:50 pm
Build a lookup table with shift_index and shift_code as follows:
shift_index shift_code
0 ...
December 3, 2007 at 12:23 pm
The query you provided will work, with a few minor fixes. The only changes I put in are in caps below, along with a missing comma in the first select...
October 23, 2007 at 4:41 pm
I think the easiest fix to your current code would be the following. Don't try to convert the input parameters, but do check the values as they are being inserted...
October 23, 2007 at 2:36 pm
A query like this will give the report you're looking for. The trick is to perform a subquery to return some valuess that can be used to identify the target...
October 19, 2007 at 5:09 pm
Viewing 11 posts - 1 through 11 (of 11 total)