Posts Tagged ‘tsql’

SQL SELECT CASE Instead of IIF

E05C0037

I’ve had to do this a couple of times and I just realized I haven’t written about it anywhere.

If you need to SELECT a field from a row that returns different content based on the content of the field, you’d think, based on previous programming experience, that your code would look something like this.

Read the rest of this entry »

Other Related Items:

The Complete Adult Psychotherapy Treatment Planner (PracticePlanners?)The Complete Adult Psychotherapy Treatment Planner (PracticePlanners?)The Complete Adult Psychotherapy Treatment Planner, Fourth Edition provides all the elements necessary to quickly and easily develop formal treatment ... Read More >
This Time is Different: Eight Centuries of Financial FollyThis Time is Different: Eight Centuries of Financial Folly

Throughout history, rich and poor countries alike have been lending, borrowing, crashing--and recovering--their way through an extraordinary range ... Read More >

Nine West Women's Ruffian Gladiator SandalNine West Women's Ruffian Gladiator SandalThe charming Ruffian Sandal from Nine West will sweep you off your feet with the allure of the stud decor and oversized buckle on its gladiator-inspired straps.

SQL – Filtering WHERE condition on two rows

iStock_000005792139Medium I received the following question a couple of days ago from a programmer using the “Ask  a Question” form which you can access from the menu of this blog:

Given the following table:

Name Language
Nikhil Hindi
Nikhil English
Kisu Hindi
Kisu English
Rakesh Hindi
Kousik Bangali

How do I select names of persons who know both Hindi and English?

In this table, that query should return Nikhil and Kisu.

Read the rest of this entry »

Other Related Items:

The Big TabooThe Big TabooThe Big Taboo is just like the Taboo you know and love, but now it has four fantastic ways to play! Race against the timer to get as many guess words ... Read More >
1Pk Oem Sql Svr 08 Std Small Bus 5 Dev Cal Only1Pk Oem Sql Svr 08 Std Small Bus 5 Dev Cal OnlyThis edition of SQL Server is an entry level edition that is intended for use in small single-server office environments with a small user base. SQL Server Standard for Small Business provides the capabilities of SQL Server Standard Edition.
Conker I Want You To Join The Squirrels Poster 1140Conker I Want You To Join The Squirrels Poster 1140
This is a standard size poster measuring 23 x 34 inches. All our posters are shipped in hard tubes for protection to prevent any bending or creasing during shipment.

Random in SQL – SQL For Programmers

IMG_1382 Last week I had an interesting assignment: Given a specific record, randomly retrieve three related records from the database.

Naturally, as a programmer, I started looking for the SQL random function.  Which I found.

But even as I was searching for how to use that function, I was thinking to myself, “How am I going to structure things in such a way so as to randomly select the records once I have the function?  It isn’t like I can retrieve the records into an array and then select them out.  Am I going to have to retrieve them into a temp table?”

Read the rest of this entry »

Other Related Items:

5 Piece Safari Animal Print Auto Interior Gift Set - 2 Snow Leopard Front Bucket Seat Covers for Truck and SUV arm rest seats, 1 Snow Leopard Steering Wheel Cover, and 2 Snow Leopard Shoulder Harness Pressure Relief Cover5 Piece Safari Animal Print Auto Interior Gift Set - 2 Snow Leopard Front Bucket Seat Covers for Truck and SUV arm rest seats, 1 Snow Leopard Steering Wheel Cover, and 2 Snow Leopard Shoulder Harness Pressure Relief CoverProduct Description Fun Safari Animal series print seat covers are made from velour to fit both low back and high back seats. Velour is a soft silky v... Read More >
Bakugan Battle Pack (Styles and Colors May Vary)Bakugan Battle Pack (Styles and Colors May Vary)The popular and fun anime TV series "Bakugan Battle Brawlers" has spawned this strategic game that pits a variety of "Bakugan warriors" -- such as "Ju... Read More >
Major Pettigrew's Last Stand: A NovelMajor Pettigrew's Last Stand: A NovelAmazon Best Books of the Month, March 2010: In her witty and wise debut novel, newcomer Helen Simonson introduces the unforgettable character of the w... Read More >

SQL CURSOR Performance – SQL For Programmers

Last week I showed how to use the SQL CURSOR to loop through records in a database.  In that article I mentioned that you want to avoid using the CURSOR if you can because it has performance problems.

The article was posted on DZone where a self-proclaimed SQL guru picked it up and left a comment basically stating an alternate way of looping through records that would do the same thing but didn’t require the CURSOR.  What he suggested was the common practice of doing something like this:

Read the rest of this entry »

Other Related Items:

Wilson Jones 362 Line Basic Round Ring View Binder, 3-Inch Capacity, 8.5 x 11 Inch Sheet Size, White (W362-49W)Wilson Jones 362 Line Basic Round Ring View Binder, 3-Inch Capacity, 8.5 x 11 Inch Sheet Size, White (W362-49W)Looks good on the shelf or on the go. Customize for filing or presentations with a non-glare overlay on the spine and front and back covers. Use the round ring open and close triggers for easy access. Take advantage of interior pockets for extra storage.
Twelve Nights in HollywoodTwelve Nights in HollywoodElla Fitzgerald's Twelve Nights In Hollywood is an unprecedented release - a 4-CD box set of 73 completely unreleased live recordings from Ella in her... Read More >
Ontel Dryer-Max Lint Removal KitOntel Dryer-Max Lint Removal KitCuts drying time and increases dryer performance. Prolongs dryer life and reduces risk of dryer vent fire. 3 piece kit includes: 10" dryer vent duct brush reaches into the dryer vent duct to remove lint build up. 36" lint trap vent brush cleans the dr

SQL CURSOR – SQL For Programmers

ka_vol1_143 One of the things it took me a while to figure out was how to get a stored procedure to loop through data in a table and pull out specific data I needed.

There are actually two parts to this question.  First, you should always try to find some other way of doing whatever it is you think you need to do by processing one row at a time.  SQL is a “Set-Based” language and as such it expects you to work with the whole set.  That’s what it was designed to do best and that’s why it has functions such as MAX, MIN, SUM, AVG, etc.  Many of these functions in combination with a good WHERE clause will get you the information you need.

However, there are times when you’ll need to process the information one record at a time, and this is what the CURSOR was created for.

Read the rest of this entry »

Other Related Items:

Brand New Atrend 12sql 12" Single Sealed Car Subwoofer Enclosure with Heavy Duty 3/4" High Density Mdf (1.0 Cubic Feet Air Volume)Brand New Atrend 12sql 12" Single Sealed Car Subwoofer Enclosure with Heavy Duty 3/4" High Density Mdf (1.0 Cubic Feet Air Volume)BRAND NEW ATREND 12SQL 12" SINGLE SEALED CAR SUBWOOFER ENCLOSURE WITH HEAVY DUTY 3/4" HIGH DENSITY MDF (1.0 CUBIC FEET AIR VOLUME) Features: Single ... Read More >
Make Money While You Sleep - Advanced Forex Auto Trading Robot - Metatrader MT4 EA - Expert AdvisorMake Money While You Sleep - Advanced Forex Auto Trading Robot - Metatrader MT4 EA - Expert AdvisorThese days it is hard to get something reliable, accurate, and affordable at the same time. Well... This system is !!!

I'm a retired Banking Prof... Read More >

Nintendo DS SoftBag -Play while ProtectedNeed a Great case to keep your prized Nintendo DS Safe? This is the one for you, with plenty of extra room for games and accessories. Protect your Nintendo DS, don't leave home with out it!
DotNetNuke Sponsor

 

Most Valuable Blogger
Sponsor