February 13th, 2014

SQL Server: Updating A Column With Random Lookup Values

This article explains how to update a table column with random values from another (lookup) table in SQL Server.

For example, Country table has two columns CountryID, CountryName and UserInfo table has CountryID column. We will update UserInfo table with random CountryIDs from Country table.

February 26th, 2012

How To Use SQL IN Statement to Select Data Having All Specified Values

Generally, We use SQL Where .. IN Statement to determine whether a specified value matches ANY value in a sub-query or a list. But sometimes we require to get data which have ALL specified values, not ANY value. In this post, we’ll see how to accomplish it. Let’s take an example, Consider following data in Orders table

January 19th, 2012

Run Your Custom Script Quickly with SSMS Tools Pack

Suppose you have to do a task repeatedly with different objects of database, for example, you have to generate code or stored procs of table in the specific format, you created your custom SQL script which takes table name and generate the code. But each time, you have to execute query and pass table name.
What’ll happen If you right click on the table and select your script to execute. It’ll save bunch of time as well as stop you getting irritated :) Let’s see how to do using SSMS Tools Pack.