Viewing 15 posts - 106 through 120 (of 128 total)
Using Query Analyzer,
Select Tools | Options | Results
check the "Output Query" checkbox.
March 2, 2005 at 10:39 am
End of month logic for "YourDate":
DATEADD(d, -1, DATEADD(m, 1 + DATEDIFF(m, 0, @YourDate), 0))
Also, first of month logic:
DATEADD(m, DATEDIFF(m, 0, @YourDate), 0)
February 18, 2005 at 2:40 pm
Your statement
select IDENT_CURRENT([linkedserver].database.table)
should be
select IDENT_CURRENT([linkedserver].database.dbo.table)
The owner is a required piece of the four-part name.
February 8, 2005 at 1:02 pm
select * from t
where DATEDIFF(m, testdate, GetDate()) > 0
February 3, 2005 at 12:06 pm
DATEADD(d, DATEDIFF(d, 0, @YourDate), 0)
This works for smalldatetime and datetime, and does not involve conversions to other datatypes.
January 26, 2005 at 9:20 am
What about this in the ORDER BY clause...
ORDER BY CASE WHEN tbl_CompanyCategories.vcName = 'other' THEN 1 ELSE 0 END, tbl_CompanyCategories.vcName
January 21, 2005 at 1:19 pm
There is no sense in updating a Field to its current value.
Update MyTable set AlteredDate = case td
when 'N' then dateadd(d, -2, ed)
else dateadd(d, -1, ed) end
where td IN ('I', 'N')
January 14, 2005 at 3:42 pm
In place of
WHERE (data.tblBooking.DateD >= GETDATE())
use
WHERE (DATEDIFF(d, GETDATE(), data.tblBooking.DateD) > 0)
No conversions, no substrings, works with or without non-midnight time portion.
January 5, 2005 at 10:33 am
Or, simply replace the offending zero in the divisor with NULL:
NULLIF((TOTAL_LOGIN_TIME - TOT_WAIT_TIME), 0)
This will cause the entire calculation to return NULL.
Then, if necessary, deal with the resulting NULL afterwards.
December 22, 2004 at 8:39 am
It appears Microsoft is doing something like "WITH TIES" behind the scenes for 100 PERCENT. However, for values other than 100 PERCENT, the resultset CAN change, as your test data...
December 1, 2004 at 9:03 am
A correction to logic posted earlier...
create view dbo.foobar
as
select top 100 percent WITH TIES * from authors order by au_lname
go
select * from dbo.foobar
drop view dbo.foobar
December 1, 2004 at 8:31 am
Newbie,
For '2004-01-30', your SQL returns 28.
This is, obviously, not the last day of the month in question, January.
Try this:
Determine the first day of the specified month;
Add 1 month;
Subtract 1 day.
DECLARE @Date datetime
SET @Date...
October 1, 2004 at 8:16 am
A NULL-safe variation of Antares' SQL changes the NULL to an empty string:
ISNULL(CASE WHEN @EmployeePhone is NULL THEN NULL ELSE '<EmployeePhone>' + @EmployeePhone + '</EmployeePhone>, '')
June 25, 2004 at 9:02 am
SELECT *
FROM YourTable
ORDER BY City, CASE YourBoolean WHEN 1 THEN NEWID() ELSE CustName END
May 28, 2004 at 12:32 pm
Viewing 15 posts - 106 through 120 (of 128 total)