You are here

Monthly archive

Rolling Back Dynamic SQL

Do transactions apply in dynamic SQL, in SQL Server? In a word, yes. For proof, run the following chunks of code:

No Transactions

You can see the third row having a value of "5", showing that it was updated

SQL Server - Download all RDL files from Report Server

---- Allow advanced options to be changed.
--EXEC sp_configure 'show advanced options', 1
--GO
---- Update the cuently configured value for advanced options.
--RECONFIGURE
--GO
---- Enable xp_cmdshell
--EXEC sp_configure 'xp_cmdshell', 1
--GO
---- Update the cuently configured value for xp_cmdshell
--RECONFIGURE
--GO
---- Disallow further advanced options to be changed.
--EXEC sp_configure 'show advanced options', 0
--GO
---- Update the cuently configured value for advanced options.
--RECONFIGURE
--GO
 
--Replace NULL with keywords of the ReportManager's Report Path,

PowerShell - Query Database Remotely

The basic syntax for sending a query to SQL Server using PowerShell.

WMI and PowerShell (Video)

PowerShell - Get Boot Time of Computer

Show Date/Time Of Last Boot

​Get-WmiObject -class Win32_OperatingSystem | Select-Object __SERVER,@{label='LastBootUpTime';expression={$_.ConvertToDateTime($_.LastBootUpTime)}}

PowerShell - Scripts Not Allowed To Run

If PowerShell is not allowing you to run scripts then you might need to set the execution policy.
Set-ExecutionPolicy RemoteSigned
https://technet.microsoft.com/en-us/library/ee176961.aspx

PowerShell - Get All SQL Server Instances In Environment

cls
import-module failoverclusters
Import-Module -Name SQLPS -DisableNameChecking



$servers = "comma","separated","server","list"

foreach($server in $servers)
{
    try
    {
    
    $virtual_name = $server;
    $instances = '';
    try{
    $virtual_name = ((get-clusterresource -Cluster $server -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | 
                        get-clusterparameter VirtualServerName -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | 

PowerShell - Fast Ping

Source: https://gist.github.com/mbrownnycnyc/9913361

This is a very fast way to ping a server using PowerShell.

PowerShell - Get SQL Server Info

$assemblylist = 
"Microsoft.SqlServer.Management.Common",
"Microsoft.SqlServer.Smo",
"Microsoft.SqlServer.Dmf ",
"Microsoft.SqlServer.Instapi ",
"Microsoft.SqlServer.SqlWmiManagement ",
"Microsoft.SqlServer.ConnectionInfo ",
"Microsoft.SqlServer.SmoExtended ",
"Microsoft.SqlServer.SqlTDiagM ",
"Microsoft.SqlServer.SString ",
"Microsoft.SqlServer.Management.RegisteredServers ",
"Microsoft.SqlServer.Management.Sdk.Sfc ",
"Microsoft.SqlServer.SqlEnum ",
"Microsoft.SqlServer.RegSvrEnum ",
"Microsoft.SqlServer.WmiEnum ",
"Microsoft.SqlServer.ServiceBrokerEnum ",

Pages

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
10 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer