Posted by Barac in SQL Server
on May 10th, 2019 | 0 comments
SentryOne Principal Program Manager, renowned database expert, founder and former president of PASS, and Microsoft SQL Server MVP, Kevin Kline, will share his deep SQL knowledge and best practices at a series of SQL Saturdays and SQL Server User Group meetings all around the world. As a part New Zealand Down Under Tour, in association with SQLMasters Consulting, Kevin Kline is coming to Auckland on June 4th to deliver a session! Push Your App to Enterprise Scale with Advanced SQL Server Features Tuesday, Jun 4, 2019, 12:00 PM Microsoft22...
Posted by Barac in SQL Server, SQL Tips and Tricks
on Mar 11th, 2019 | 0 comments
Same as in previous posts examples Expanding Tables List Query and Expanding Columns List Query I usually do not notice this type of queries working in the background. But recently I end up working with a customer having DB with over 500K indexes, 150K tables and expanding indexes list operation can end up being slower than usual. Here is the code: SELECT i.name AS [Name], 'Server[@Name=' + quotename(CAST( serverproperty(N'Servername') AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Table[@Name=' +...
Posted by Barac in SQL Server, SQL Tips and Tricks
on Mar 5th, 2019 | 0 comments
Same as in previous post example Expanding Tables List Query I usually do not notice this type of queries working in the background. But recently I end up working with a customer having DB with 150K tables, some of the tables have more than 500 columns, and expanding columns list operation can end up being slower than usual. Here is the code: SELECT clmns.name AS [Name], 'Server[@Name=' + quotename(CAST( serverproperty(N'Servername') AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Table[@Name=' +...
Posted by Barac in SQL Server, SQL Tips and Tricks
on Mar 3rd, 2019 | 0 comments
Usually I do not even notice this query working in the background, since this operation is quite fast. But recently I end up working with a customer having DB with 150K tables, and expanding table list operation can be really slow and expensive. Here is the code: SELECT tbl.name AS [Name], SCHEMA_NAME(tbl.schema_id) AS [Schema], 'Server[@Name=' + quotename(CAST( serverproperty(N'Servername') AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Table[@Name=' + quotename(tbl.name,'''') + ' and @Schema=' +...
Posted by Barac in Powershell, SQL Server, SQL Tips and Tricks
on Feb 12th, 2019 | 0 comments
Restore multiple TRN logs using PowerShell. In this example I will show you really simple way how you can use PowerShell to restore multiple logs at once. After restoring full backup WITH NORECOVERY you need to figure it out last log sequence number of the last transaction in the backup set. TRN Log backups must be restored in the order in which they were created. Log backups contain log sequence numbers (LSN), and they must be restored in that particular order. There are few ways to find last LSN. USE msdb GO SELECT TOP 10 bck.database_name...
Posted by Barac in Azure, Powershell
on Jan 21st, 2019 | 0 comments
Script Download: The script with usage example is available for download from https://gallery.technet.microsoft.com/Deploy-Azure-SQL-DR-47dfa7f7 Summary: Use PowerShell to create cloud DR environment using Azure SQL Databases (PaaS) and send Email Report with the connection string details Description: Use PowerShell to deploy cloud service with Azure SQL Database (PaaS) with good resilience to outages (GEO Replications, Failover Groups) PowerShell: Connect to Azure Account, Use existing or create new Resource Group, Create primary...