Author Archives: Horia

Add UNIQUE constraint WITH NOCHECK ? Not really …

Ever wanted to add a UNIQUE constraint WITH NOCHECK ? Maybe you had some duplicates in your data, fixed the code, but you cannot remove the duplicates, or maybe it’s a “temporary” thing.
Read more »

Automating restores for Ola Hallengren backup solution

While going through Brent Ozar’s 6-Month DBA Training Plan, I got myself a good challenge quite fast, after reading “Automating Restores” – to automate restores on backups taken using Ola Hallengren Backup Solution. Read more »

Passing a DataTable as table parameter from C# to stored procedures using table type

So may times I’ve seen useless loops to save many rows of data into a table, where data was captured in the front end part of the application. And sometimes, the row number was quite high – for example, where user was filtering some rows available to him, or imported from a data source like excel or access mdb file. Read more »

Safe exit from WHILE loop using ##global temp tables

Loops, SQL Server – these two things don’t go along as best friends, but every once in a WHILE, there’s no other way around. If I also add transactions, i surely want to have full control over it.
Read more »

PowerShell to start/stop Sql Server on localhost

With a #notsogreat personal laptop, and having a lot of things installed, my laptop runs a bit slower. When I install sql server, i usually configure the services to start manually, so I can just start them when I need them. Read more »

Order NULLs last (numeric only)

Every now and then I need to sort data by a numeric value and NULLs always come first. And I want them last.
Read more »

Table size growth when converting columns – VARCHAR to INT

How many times have you seen VARCHAR columns holding INT (or NULL) values only ?
Read more »