September 2007 Blog Posts
We're all familiar (i hope :)) with this construct:try
// ... some code here ...
catch (Exception ex)
// one of these 2 lines are usually seen
throw; // presereves the full call stack
//throw ex; // changes the origin of exception to this method
// more stuff here
It's a standard error catching routine in .Net.
But what if you want to pass some user info back to the caller method with the Exception being thrown?
Reader... meet Exception.Data. Exception.Data... meet reader.
Now that you're both properly aquainted...
SSMS Tools Pack is an Add-In (Add-On) for Microsoft SQL Server Management Studio 2005 and
Microsoft SQL Server Management Studio Express 2005.
It contains a few upgrades to the IDE that I thought were missing from Management Studio.
- Query Execution History (Soft Source Control): saves every query text you execute in a file or in a database
- Text document Collapsable Regions and Debug sections: regions and debug section known from Visual Studio which are missing in SSMS
- New query template: set the template that will open when you open a new query
- CRUD (Create, Read, Update, Delete) stored procedure generation:...
Indexes are a constant problem in understanding for beginners (and the "not so beginners") in the database world. And don't you just love the
hardcore mathematical explanation of B-Trees and their traversal. Personaly I much rather have visual props and a story to support an explanation.
Appealing visual props are even better. That's how this post originated. So let us begin!
Imagine you live in a pre-computer-in-every-nook-and-crane world (around 1960's :)).
You wake up one morning with a huge craving to read Agatha Christie's books. So you go to the library which has a few million books.
You walk up to the cute librarian (look...
You wouldn't believe how many times i've seen this code
IF (SELECT COUNT(*) FROM Table1 WHERE ... ) > 0
It's understandable though. Logically it's the easiest way to write "if there are any rows matching my condition do this".
But it's also wrong. Plainly and simplly wrong!
Because when you do a count(*) there is no way to get around an index range scan or a full table scan. For a large resultset this will be a huge resource hog.
So how do i do this you might ask yourself?
Very simple: Use EXISTS!
IF EXISTS(SELECT * FROM Table1 WHERE ...)
Exists stops the execution as soon as...
I've been asked this question so many times now that it'd be easier if i just gave people a link to read. :)
So in short (for those who are too lazy to dwelve deeper into sql internals):
Each row has a null bitmap for columns that allow nulls. If the row in that column is null then a bit in the bitmap is 1 else it's 0.
For variable size datatypes the acctual size is 0 bytes.
For fixed size datatype the acctual size is the default datatype size in bytes set to default value (0 for numbers, '' for chars).
Let's have two simple table t1 and t2....
I haven't been using this function at all. Who knows why... maybe because i didn't know about it :)
But in my latest pet project i had to do something really quickly on a lot of items in a list.
After a bit of research into foreach and for loops, i saw the List<T>.ForEach method.
Did some testing and sure thing List<T>.ForEach proved to be faster than others.
I thought about posting the whole setup and how i've tested it, but then i saw that Dustin Russell Campbell
did exactly the same thing a bit more thoroughly, so why double it up, right?
Read it, like...