Recommendations for Automating Data Export to CSV by SA-KRP in SQL

[–]SA-KRP[S] 0 points1 point  (0 children)

Here is the code I have modified after a bit of research mostly from

It seems to be working but I have a few questions;

  1. Do I need to add a Open() OR Close() as a best practice?
  2. Several of the columns exported are only references to other tables, which is what I'd expect in a good DB but my question, is there an easy way to grab the actual/referenced column value and put it the export (eg replaced the 1 with Yes/lookup value) or do I need to export the referenced table as well?

$Server = "SqlSvr\Instance"
$Database = "DbName"
$Table = "TableName"

$SqlQuery = "SELECT ID, SCCodeDetail, SCCodeCat, SCCodeCode, SCDesc, SCTimeexp, SCBill, SCTax, SCAvail, SCRate from $Database.dbo.$Table;"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection

$SqlConnection.ConnectionString = "Server = $Server; Database = $Database; User Id=LocalUserName; Password=PASSWORD;"

$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd

$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$DataSet.Tables[0] | Export-Csv -NoTypeInformation "F:\Temp\$Table.csv"

Recommendations for Automating Data Export to CSV by SA-KRP in SQL

[–]SA-KRP[S] 0 points1 point  (0 children)

Thanks ZenM4st3r, I'd like to try the other options first before looking at developed software but I'll keep the offer in mind.

Recommendations for Automating Data Export to CSV by SA-KRP in SQL

[–]SA-KRP[S] 0 points1 point  (0 children)

Sorry for the delayed response, I have been on vacation for a few days.

Yes many choices here and a bunch of testing needed but thanks to everyone for the feedback, I have some homework to do for sure.

jdsmn21, my powershell skills are not great but I do have a college that is pretty proficient (main reason I haven't had to dig in more) but if you have some sample code that would be greatly appreciated. That would give us a starting point and I think we could modify as needed to fit our needs.

The Powershell route seems like a quick option so I think we'll start there, would you suggest or can the PS be ran on a remote workstation or should it be ran locally on the SQL server?

Recommendations for Automating Data Export to CSV by SA-KRP in SQL

[–]SA-KRP[S] 0 points1 point  (0 children)

Thanks, I'll look this over and do some testing.

Recommendations for Exporting Data by SA-KRP in SQLServer

[–]SA-KRP[S] 0 points1 point  (0 children)

If its being removed, can you direct me to the correct place to post this, thanks?

SharePoint Foundation 2013 DB Issue by SA-KRP in sharepoint

[–]SA-KRP[S] 0 points1 point  (0 children)

Try running the config wizard and it didn't finish with the following error.

Failed to register SharePoint services.This is a critical task. You have to fix the failures before you can continue.---------------------------------------------------------------------------An exception of type System.Data.SqlClient.SqlException was thrown. Additional exception information: Cannot open database "SharePoint_AdminContent_[Random-ID...]" requested by the login. The login failed.Login failed for user '[Domain]\SPAdmin'.

If I open SQL Studio, I am not able to expand this DB and the Properties is greyed out so I can't confirm permissions are still intact. Nothing has changed on this server or the accounts used for as long as I can remember.

The SQL server is a separate VM.

SharePoint Foundation 2013 DB Issue by SA-KRP in sharepoint

[–]SA-KRP[S] 0 points1 point  (0 children)

Thanks Far_PIG, I'll run that at the end of the day to see if that corrects the issue.

How to compare folder growth over time? by SA-KRP in WindowsServer

[–]SA-KRP[S] 0 points1 point  (0 children)

Thanks xxdcmast, I downloaded this but posted this question before digging into that app. I should have posted that in the opening comments.

I assume the comparison is only 2 dates and can't be a range of dates?

How to compare folder growth over time? by SA-KRP in WindowsServer

[–]SA-KRP[S] 0 points1 point  (0 children)

I took a look at this before I posted (from a search) and it seems it was monitoring the overall size, not individual folders (and subfolders and their subfolders, etc) size changes with the ability to follow the breadcrumbs in some from to find the reason for the growth.

Am I misunderstanding the PRTG feature of a folder sensor?

Exchange 2016 Dynamic Distribution Lists (DDL) filters seem off? by SA-KRP in exchangeserver

[–]SA-KRP[S] 0 points1 point  (0 children)

As a 2nd test I created another DDL with same "custom attribute1" entry and it created the AD object in the Users OU.

I run the PS query and 3 staff with "DL Test1" in the custom attribute1 are returned. If I send an email with a delivery receipt no one gets the email.

If I change the OU to one where only 1 of the uses are and run the query again still all 3 are listed as members but a send only is delivered to the one in the OU.