how to find a date – in SQL Server

#1 – create table

DbName varchar(255),
TblName varchar(255),
ColName varchar(255)

#2 – run this in a database

Select ‘insert into TheDates(TheDate, DbName, TblName, ColName) Select DATEADD(day, DATEDIFF(day, 0, [‘ + + ‘]), 0) as TheDate, ‘ + char(39) + DB_NAME() + char(39) + ‘ as DbName, ‘ + char(39) + + char(39) + ‘ as TblName, ‘ + char(39) + + char(39) + ‘ as ColName From [‘ + DB_NAME() + ‘].dbo.[‘ + + ‘] with (nolock) WHERE [‘ + + ‘] IS NOT NULL’ + CHAR(10) + ‘go’

from sysobjects so
inner join syscolumns sc
on =
where so.xtype = ‘u’
and TYPE_NAME(sc.xtype) in (‘smalldatetime’, ‘datetime’)
AND not like ‘MS%’

#3 – take the output from step#2 and re-run it in a new database window.


Now you will be able to have a single date table that lists every date in your database.

This is a work-around for when I have a MASSIVE number of columns, for example, I’m doing this on ~850 columns right now, it should just take about 5 minutes

I’m basically trying to determine.. which tables / date columns got a LARGE number of new rows / values today.. Because I just ran a bunch of ETL jobs


14 Reasons To Fire Your IT Staff

  1. A lobbyist for a Windows 8 Start button. Progress means sometimes evolving the UI. If an IT pro can’t handle a new Start button, how is he handling your other technologies?
  2. An administrator cites security as a reason for not implementing DirectAccess. Yesteryear’s VPN required complex choreography for a basic Layer 2 connection.
    DirectAccess is always-on and bidirectional. “Every laptop always under management” isn’t insecure — it’s exceptionally secure.
  3. An admin is still installing applications manually. Technologies that automate software installations are two decades old. Enough said.
  4. Your Exchange e-mail goes down. Exchange these days offers multiple, overlapping high availability (HA) technologies. If your admin lacks experience to implement them, a cloud service can — and can potentially do so at a lower cost.
  5. Requests spend more time in committee than getting provisioned. Change Control Boards (CCBs) are IT’s best effort yet in impeding business requests in the name of coordination.
  6. An administrator offers virtual desktop infrastructure (VDI) solutions without understanding Remote Desktop Services (RDS). RDS is a cheaper, denser, simpler version of VDI that’s also nearly two decades old. RDS doesn’t work for every application — but it does work for most.
  7. An admin hasn’t explored a single cloud service. Good cloud services are an organic evolution of on-premises IT.
  8. An admin foregoes monitoring because “it’s too noisy.” Devoid of monitoring, Gartner’s IT Management Process Maturity Model labels an IT organization as “chaotic.” Tools like System Center Operations Manager aren’t trivially easy, but they’ve become funda­mentally necessary.
  9. An administrator is still creating user accounts instead of leaving that to HR. Active Directory Users and Computers is the Windows world’s least-efficient solution for creating user accounts, particularly with System Center Orchestrator and other workflow solutions. It only takes a little up-front automation effort to pay long-term efficiency dividends.
  10. Your backups fail. Backups sometimes fail, but not knowing they have is professional suicide. Intelligent backup technologies have evolved substantially in recent years. A catastrophic loss today is justifiable evidence of negligence.
  11. An admin’s Active Directory team hoards Group Policy. Repeat after me: Group Policy has nothing to do with Active Directory. In fact, Group Policies do more for desktop management than anything else. Keeping these technologies from those who benefit most signals fiefdom-building over cooperation.
  12. An admin stares, clueless, at Invoke-Command. Years have passed since Windows PowerShell became a must-know skill in Windows management. Today, one must grok Windows PowerShell and Windows PowerShell remoting to be considered a whole Windows IT person.
  13. Users still configure applications. Users should come to work to use applications, not configure them.
  14. An admin hands you this column and starts explaining.