0

I am trying to use one table to store the SQL server disk space checking data by dbatools:

$allservers_PRD | Get-DbaDiskSpace | Write-DbaDbTableData -SqlInstance MySQL2019 -Database SQL_DBA_TASK -Table SQL_DISK_SPACE -AutoCreateTable

How can I add timestamps (what is the checking time) into my table rows as addition column when I use it?

Many thanks,

2
  • Thank you very much, that works fine! – DBALUKE HUANG Jul 29 '20 at 20:44
  • Added it as an answer below. – LowlyDBA - John M Jul 29 '20 at 21:23
1

When I was arranging a similar setup in the past, I did the following:

  1. Use -AutoCreateTable to generate the basic schema for any commands I wanted to write to the database
  2. Modify the tables to use better data types + added a column with a default GETDATE() value
  3. Pipe any results into the newly modified tables.

This is also helpful since any updates to the command output will break due to schema differences and force you to adjust the code and table as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.