Showing posts with label t-sql. Show all posts
Showing posts with label t-sql. Show all posts

Monday, June 30, 2014

I like to move it, move it. Upload and download binary data to or from SQL Server using standard tools

Imagine that you have a huge collection of Hello Kitty images (I do).
One day you make a decision to organize your collection - sort it, label it, tag it, remove duplicates and so on. The first thing you need - sophisticated data storage, of course. And it is obvious that you choose SQL Server - the world's best database platform :)
And since SQL Server is already present in our Universe - how about to load binary data into it?

Sunday, June 15, 2014

Script, store and transfer data using XML, XQuery and clipboard

When surfing SQL Server forums you might notice a lot of questions like "How do I script my data and transfer it to another server?". Of course these questions always have answers,  from "Nohow" to "Use SSMS 2012/ SSMSBoost/ SSMS Toolpack". But what can you do if you don't have neither SQL Server 2012 nor any 3rd party tools (quite useful by the way).

Monday, June 9, 2014

Don't mess with success or Everybody lies.

Imagine that you have a table of customers
create table Customer
(
Name varchar(30),
LastName varchar(30),
Title varchar(30)
);
go
insert into Customer values('Alex','Smith','Mr.');
insert into Customer values('John','Doe','Dr.');
go
Now you selecting list of customers
select    c.Title + ' '+ c.Name +' '+c.LastName as Name from dbo.Customer c
order by Name
Just as planned!
Here is a list of customers, perfectly sorted.

To be sure that your query has no issues you test it with SQL Code Guard.
What a pity!

Tuesday, May 20, 2014

Varchar "miracle" and best practice

I've just spent fifteen minutes helping colleague to find "miracle in t-sql code".
- There should be rows, definitely! I can run simple query and voila! 4 thousands of rows selected! So why there are no rows when I'm doing a simple left join with small filter expression?
There is no miracle of course.