🔥 Burn Fat Fast. Discover How! 💪

Sitecore lifehack: Sometimes you may need getting raw SQL-lev | Sitecore Telegram

Sitecore lifehack:

Sometimes you may need getting raw SQL-level access into your Sitecore databases, but you may not get relevant tools (SSMS) or even database access. No worries, if you've got SPE - you can still do all that you want, and this is how:

# use @"_query_"@ for multiline synthax
$sql = "SELECT GETDATE() AS TimeOfQuery"
Import-Function Invoke-SqlCommand
$db = Get-Database -Name "master"
$conn = [Sitecore.Configuration.Settings]::GetConnectionString($db.Name)
Invoke-SqlCommand -Connection $conn -Query $sql

But what for? There might be plenty of valid reasons to do so. Here's just on example of: https://tinyurl.com/2w72nvv5