Viewing 15 posts - 1,966 through 1,980 (of 3,011 total)
The code below is the standard way to get a date without the time in SQL Server.
Extensive testing (by me and many others) has shown that casting a date...
March 11, 2009 at 10:23 am
select
*
from
MyTable
where
-- Date greater than or equal to Monday of last week
MyDate >= dateadd(dd,((datediff(dd,'17530101',getdate())/7)*7)-7,'17530101')
and
-- Date before Saturday of last week
Mydate < dateadd(dd,((datediff(dd,'17530101',getdate())/7)*7)-2,'17530101')
March 11, 2009 at 10:07 am
Shorter.
select [Month] = right(100+month(getdate()),2)
Results:
Month
-----
03
March 11, 2009 at 7:33 am
LoveSQL (3/10/2009)
Well the back end is SQL 2000 not SQL 2005thanks!
So why did you post your question in the SQL Server 2005 forum?
March 10, 2009 at 9:15 pm
The code should do what you want. Change the DB name from "test" to the database you are working with.
use master
go
declare @kill_spid varchar(20)
-- Find spid of user connection to...
March 10, 2009 at 3:45 pm
select
[SQL Server Start Time]= convert(varchar(23),a.SQL_Start,121),
[SQL Agent Start Time]= convert(varchar(23),a.Agent_Start,121),
[SQL Uptime] =
convert(varchar(15),
right(10000000+datediff(dd,0,getdate()-a.SQL_Start),4)+' '+
convert(varchar(20),getdate()-a.SQL_Start,108)) ,
[Agent Uptime] =
convert(varchar(15),
right(10000000+datediff(dd,0,getdate()-a.Agent_Start),4)+' '+
convert(varchar(20),getdate()-a.Agent_Start,108))
from
(
Select
SQL_Start = min(aa.login_time),
Agent_Start =
nullif(min(case when aa.program_name like 'SQLAgent %' then aa.login_time else '99990101' end),
convert(datetime,'99990101'))
from
master.dbo.sysprocesses aa
where
aa.login_time...
March 10, 2009 at 9:29 am
This change to the inner WHERE clause will fix your problem. Conditions in a CASE statement are evaluated in order, so only values that pass the ISDATE checks will...
March 10, 2009 at 8:59 am
Bob Hovious (3/6/2009)
By the way, does anyone else here follow the online comic XKCD? ...
March 6, 2009 at 11:15 pm
Instead of this being a club, I like to think of SSC as more like a bar. Come in, set down, have a cold one, and start spouting off...
March 6, 2009 at 6:56 pm
select
FirstMondayOfMonth =
dateadd(dd,(datediff(dd,'17530101',SeventhDayOfMonth)/7)*7,'17530101'),
FirstTuesdayOfMonth =
dateadd(dd,(datediff(dd,'17530102',SeventhDayOfMonth)/7)*7,'17530102'),
FirstWednesdayOfMonth =
dateadd(dd,(datediff(dd,'17530103',SeventhDayOfMonth)/7)*7,'17530103'),
FirstThursdayOfMonth =
dateadd(dd,(datediff(dd,'17530104',SeventhDayOfMonth)/7)*7,'17530104'),
FirstFridayOfMonth =
dateadd(dd,(datediff(dd,'17530105',SeventhDayOfMonth)/7)*7,'17530105'),
FirstSaturdayOfMonth =
dateadd(dd,(datediff(dd,'17530106',SeventhDayOfMonth)/7)*7,'17530106'),
FirstSundayOfMonth =
dateadd(dd,(datediff(dd,'17530107',SeventhDayOfMonth)/7)*7,'17530107')
from
(
Select SeventhDayOfMonth = dateadd(month,datediff(month,0,getdate()),0)+6
) a
March 6, 2009 at 3:29 pm
You can also just right-click on a table in the SSMS object explorer, and pick Script Table as, SELECT
March 6, 2009 at 7:56 am
t.walker (3/5/2009)
This is not a sarcastic point...
March 5, 2009 at 9:56 pm
SQL Server 2008 Books Online (February 2009)
What's New (SQL Server 2008)
http://msdn.microsoft.com/en-us/library/bb500435.aspx?ppud=4
March 5, 2009 at 9:42 pm
Being an MVP would be cool, but nothing beats basking in the warm glow of my own genuine and heartfelt self admiration. :satisfied:
March 5, 2009 at 8:59 pm
There is real value in responding to even really stupid posts by people that are completely clueless and hopeless in their stupidity.
If no one responds to those sorts of things,...
March 5, 2009 at 8:43 pm
Viewing 15 posts - 1,966 through 1,980 (of 3,011 total)