|
![]() |
|
|||||||
![]() ![]() webhalla Dutch Data Protection Authority @toezicht_AP measured the number of data theft reports in 2020 and it skyrocketed. It increased 30% in 2020 compared to 2019. Less data breach reporting, more hacking, malware & phishing. #GDPR #Privacy #DataBreach Use #MFA https://t.co/owmjDbwMgO https://t.co/tHQS5XzEf0 01 Mar 2021 Brabantia together with #WeForest are growing already more than 2 million #trees ! Awesome #reforesting of #Africa ! As an employee of #Brabantia some are planted on behalf of me. https://t.co/3GL7vVIKWT https://t.co/llCSHoSo0S 27 Feb 2021 Last Friday the @EU_Commission released two draft #GDPR #EU and #UK #adequacy decisions. If approved, the proposals would allow for data to continue to flow between commercial and law enforcement sectors. Thanks @PrivacyPros #privacy https://t.co/q9iGgox4vm https://t.co/GCjJ9DoW4j 22 Feb 2021 EUCouncil agreed on #ePrivacy (#protection of #privacy and #confidentiality using #electronic #communication #services) rules. Applies to end-users in the #EU #EUCouncil start talks with #EUParliament on final text. ePrivacy will be lex specialis to #GDPR. https://t.co/FajvFTRt29 https://t.co/WO2Rn30UZI 11 Feb 2021 Dutch Supervisory Authority @toezicht_AP will grow significantly from 184 to 470 FTE. More employees for investigating possible #databreaches and reported data breaches. #gdpr #privacy #Security https://t.co/iP5QWMMg4L https://t.co/x1Xg6JGqaa 09 Feb 2021 |
ICT-Hotlist TopicHow to export a table from Microsoft SQL server 2008r2 to Excel using PowerShellBefore PowerShell you had to use the Microsoft SQL Query Analyzer to export data to Excel (or query the database from Excel when allowed). This tip compares a simple query using SQL Query Analyzer versus PowerShell.The example: get all the records of the table Person.Contact from the AdventureWorks sample database. Standard Query reportThe data can be extracted using the Microsoft SQL Server Management Studio or Microsoft SQL Query Analyzer by running the query:
-- ****************************************************************************
Make sure you click the "Results to File" output selection button before running this script.
-- * This script displays all records / tuples of the table [Person].[Contact] -- * from the Microsoft SQL Server sample database AdventureWorks -- * (C)Copyright 2012 - 2021 Johan van Soest http://www.vansoest.it -- **************************************************************************** SELECT * FROM [AdventureWorks].[Person].[Contact] Save the Report file under the name you select. Next you have to import and format the Report output file for use in Excel. PowerShell Query versionWhen using Microsoft SQL Server 2008r2 Management Studio, right click anywhere on the database tree and select "Start PowerShell" as can be seen in the next image:![]() Start a Microsoft SQL Server PowerShell command window This opens a SQL Server PowerShell window that will accept commands right away.The following instruction will:
Invoke-Sqlcmd
-Query
"SELECT * FROM [AdventureWorks].[Person].[Contact]" |
Export-Csv
c:\Share\AdventureWorks.Person.Contact.CSV
-encoding
"unicode"
The file "AdventureWorks.Person.Contact.CSV" is placed on the shared folder
"c:\Share" on the SQL server and can be opened right away using Microsoft Excel 2007 or newer.
![]() Presentation of the table Person.Contact from the AdventureWorks sample database in Microsoft Excel The SQL Server PowerShell command window closes by typing "exit". This example can be extended to more complex queries such as joins and where filters. PowerShell command line versionYou can also run Microsoft SQL Server PowerShell scripts on the Command line on a machine where the SQL Server PowerShell plugins are installed. The PowerShell modules are installed by default when installing Microsoft SQL Server. You can manually install the PowerShell Extensions for SQL Server 2012, 2014 or 2016 by installing the following components from the Microsoft® SQL Server® 2016 Feature Pack:
#############################################################################
# This script displays all records / tuples of the table [Person].[Contact] # from the Microsoft SQL Server sample database AdventureWorks running on # this computer (localhost) using PowerShell on the command line # (C)Copyright 2016 - 2021 Johan van Soest http://www.vansoest.it ############################################################################# # Load the Microsoft SQL-Server snap in modules Add-PSSnapin SQLServer* # Setup the query statement $Query = "SELECT * FROM [AdventureWorks].[Person].[Contact]" $DataBase = "AdventureWorks" $ServerInstance = "localhost" # Open the database connection, get a result set and save it as a Unicode CSV file. Invoke-Sqlcmd -Query $Query -Database $DataBase -ServerInstance $ServerInstance | Export-Csv c:\Share\AdventureWorks.Person.Contact.CSV -encoding "unicode"
You may vote your opinion about this article:
![]() ![]() ![]() ![]() ![]() Scripts and programming examples disclaimerUnless stated otherwise, the script sources and programming examples provided are copyrighted freeware. You may modify them, as long as a reference to the original code and hyperlink to the source page is included in the modified code and documentation. However, it is not allowed to publish (copies of) scripts and programming examples on your own site, blog, vlog, or distribute them on paper or any other medium, without prior written consent.Many of the techniques used in these scripts, including but not limited to modifying the registry or system files and settings, impose a risk of rendering the Operating System inoperable and loss of data. Make sure you have verified full backups and the associated restore software available before running any script or programming example. Use these scripts and programming examples entirely at your own risk. All liability claims against the author in relation to material or non-material losses caused by the use, misuse or non-use of the information provided, or the use of incorrect or incomplete information, are excluded. All content is subject to change and provided without obligation. |