Monday, March 26, 2018

Select = date without timestamp with sql

you may have a data for date column with timestamp
eg: 2018-03-26 13:40:22.470

let's say you need to check the date eg: 2018-03-26

Then you need to take part of the date string. you have various options, here i use convert()

 select count(*)
  -- convert(varchar(10),LastErrorOccurredDate,120)
 from Mytable (nolock)
 where convert(varchar(10),LastErrorOccurredDate,120) ='2018-03-26'

Thursday, March 22, 2018

Extracting list of windows services and their status to a text file

Below will extract details of windows services to a text file

Get-Service | Export-Csv -path "C:\Services\services.csv"

With below you can retrieve the running windows services list

Get-Service | where {$_.Status -eq "Running"} | Export-Csv -path "C:\Service\services.csv"