NOTE: These methods do not yet take in to account the ability to address absence codes you have defined as not enrolled. This newer flexibility allows a day not to count at all for special circumstances such as an IEP that says not attending on Friday, temporary foster arrangement making a student incapable of attending for a short period of time, or short term incarceration.

Two PowerShell scripts are included. 

ATTpercentage.PS1 instructional video...

PeriodATTpercentage.PS1 instructional video...

Exporting with powershell prerequisites:

You will have to run under SQLPS (SQL PowerShell extensions which will be on a typical SQL server or you must install SQL feature pack files...)

SQL Server 2016 Feature Pack (newest available connects to down level servers just fine)

1. ENU\x64\SQLSysClrTypes.msi

2. ENU\x64\SharedManagementObjects.msi

3. ENU\x64\PowerShellTools.msi

NOTE: You also need a current .NET Framework installed on the machine you run this. Newer operating systems like Windows 10 ships with .NET 4.6 and will receive updates.

Example Code:

Tab Delimited Export:

Invoke-Sqlcmd -serverinstance tcp: -database DST16000AeriesDemo_ID - username MyUserID -password MyPassword -query "select * from STU" | ConvertTo-Csv -NoTypeInformation -delimiter "`t" | % {$_.Replace('"','')} | out-file C:\WhateverDirectory\TAB.txt

Naturally straight to CSV comma delimited is easier syntax...

Invoke-Sqlcmd -serverinstance tcp: -database DST16000AeriesDemo_ID -username MyUserID -password MyPassword -query "select * from STU" | Export-Csv C:\WhateverDirectory\plainold.csv -NoTypeInformation