Posts

Showing posts with the label CSV

Query within a Task Scheduler Library folder using schtasks.exe and getting total number of tasks

As we all know that working with task scheduler is not an easy task when it comes to query, change, add etc. through the command prompt. Here i will share few of the details while working with schtasks.exe. What is Schtasks.exe ? Schtasks enables an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote computer. Running Schtasks.exe without arguments displays the status and next run time for each registered task. For more information to work with Schtasks follow the link " https://docs.microsoft.com/en-us/windows/desktop/taskschd/schtasks " Now lets get back to what our topic concerns -  Query within a Task Scheduler Library folder using schtasks.exe and getting total number of tasks. For Query we just use  - schtasks.exe /query /TN \[FolderName]\ Now to query and get the number of tasks we will follow below process : Just for an example I'm working for two folder - \Microsoft\Windows\SideShow and \Micros

Export Data as csv file from SQL server using command line tools

In the post we will be discussing about the ways of exporting data from SQL server to csv file. As per the use case the output should have: Header row The seperator of columns should be ",". The file should be encoded as UTF-8. There are two tools for exporting data from SQL Server to csv file. These are sqlcmd and bcp. SQLCMD The command which can be used for this purpose is Sqlcmd -S "<ServerName\InstanceName>" -d "<DatabaseName>" -U "<UserName>" -P "<Password>" -i "<SQLScriptFilePath>" -W -f 65001 -h -1 -s "," -o "<OutputFilePath>" E.g.:  Sqlcmd -S "10.00.00.00" -d "EmployeeDatabase" -U "User1" -P "Password" -i "Script1.sql" -W -f 65001 -h -1 -s "," -o "c:\File.csv" Attributes -W is used to remove all the whitespaces -h -1 is used to remove the header (if header is not remo