Here’s a simple example on how to encrypt (and decrypt) values in SQL Server:
--How to Encrypt and Decrypt Text in SQL Server (2008+)
--Example by Clint Huijbers
@Key1 NVARCHAR(50) = N'8g87g8ag4r8hinsg^%$#F&^F&^F^F&ÛIBOUG(%*^R&$%&#%^C5'
,@Key2 NVARCHAR(50) = N'&*^%R%^**F$F*OUYBYUB*F%74d654d7f685f65f56f6v6vc88d'
,@ValueToEncrypt VARCHAR(150) = 'This is the value that will be encrypted by the built-in function of SQL Server with two keys and 128-bits encryption :) blablablablablablablablablabl'
,@EncryptedValue VARBINARY(350) --Increase the VARBINARY size when you increase the lengh of @ValueToEncrypt!
SELECT @EncryptedValue = ENCRYPTBYPASSPHRASE((@Key1+N'||'+@Key2),@ValueToEncrypt)
--Search for a specific string in object-definitions:
o.name AS Object_Name
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id = o.object_id
WHERE m.definition Like '%SELECT%'
--Find a column within the database:
t.name AS TableName,
SCHEMA_NAME(schema_id) AS SchemaName,
c.name AS ColumnName
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%Customer%'
ORDER BY SchemaName, ColumnName
Couple of weeks ago, I shared my SSRS dashboard with the community on LinkedIn:
Koos van Strien asked for the source (RDL) and restyled the dashboard with his ‘webdesign-look’. Pretty nice!
Koos discusses the changes he made to my dashboard on his blog:
Here are both dashboards in full size:
Did you know that by pausing the SQL Server service before restarting the instance we allow end users to continue their work uninterrupted and we also stop any new connections to the instance? This is a nicer way of telling people to “get out” of the database in order for the server to be rebooted. I wouldn’t leave the server paused for 60 minutes of course, but I would rather use this method than forcibly disconnect users and rollback their transactions.
When a server is paused you will see messages similar to this in the SQL Server error log:
Error: 17142, Severity: 14, State: 0.
SQL Server service has been paused. No new connections will be allowed. To resume the
service, use SQL Computer Manager or the Services application in Control Panel.
Error: 18456, Severity: 14, State: 13.
Login failed for user ''. Reason: SQL Server service is paused.
No new connections can be accepted at this time. [CLIENT: ]
Next time you are worried about rebooting during the day think about the pause button instead. It might be a nice compromise for your end-users.
Thank Thomas Larock for his blog post: http://thomaslarock.com/2016/01/pause-sql-server-service-before-restarting/
The SQL Server Management Data Warehouse (MDW) is one of the most underappreciated features of SQL Server. But it’s a really handy feature which logs WaitStats and more, with almost no overhead (< 1% CPU). And…it does generate some nice reports which you could use to monitor your server (out of the box):
How to enable it
For more info (and how to enable it), please visit:
Stumbled upon this great post by Marco Schreuder about how to collect source system metadata with T-SQL queries:
The blog post is a few years old, but still the queries might come in handy.
TSQL Metadata Queries
1. Get column information from all tables
2. Get column information from all views
3. Get details of foreign key constraints
4. Get details of the indices created on user tables
Yesterday I attended Hope Foley‘s webinar during 24 Hours of PASS, thanks for that!
A few examples:
Here’s Michael Coles Christmas card of 2009:
Here’s a great example by Michael J Swart:
How can I create such art?
Well Alex Whittles explains how you could accomplish this on his blog:
Besides that it’s cool, a more practical use for spatial data is for example if you’re in the hotel of conference business.
Imagine a report that displays your floor layout and also if a room is occupied or not? Perhaps also to display block-reservations (groups), like for example for SQL Saturday or when your local footbal club is staying at your hotel?
Here’s an example: