Microsoft announces SQL Server 2008
MS SQLWait a minute... I'm still using SQL Server 2000!!!!
Looks like some cool stuff coming, including a new "merge" statement. Kinda like and update and insert statement all in one. Check out some details over at SQLTeam.com.
http://www.sqlteam.com/item.asp?ItemID=26945
Good Day!
Ryan
Removing Duplicates
MS SQLEvery once in a while I'll load a temporary table up with data before I load it into a production table so I can do some manipulation of the data if needed. Today I was in the process of loading data into the production table when I noticed there were some duplicate entries in the data I was loading. In fact there were many duplicates. I did some searching and I found this code, it removes the duplicate records, leaving just one entry.
The code code was found at SQL Server Magazine's web site at the address below.
http://www.sqlmag.com/Article/ArticleID/21704/sql_server_21704.html
Hope this helps, I know I'll use it again.
Good Day,
Ryan
NULLS: SQL Server 2000 vs SQL Server 2005
MS SQLThe following information came from the SSWUG.ORG newsletter I get daily. I thought it was interesting and thought I'd share it.
We've run into an oddity, or at least something to be aware of, when moving to SQL Server 2005 from 2000. If you have a column that is a varchar() that allows NULLs, and you're using ADO to access your SQL Server, there is at least one case where you can get different results back. The case is specifically where you're looking to get the len(gth) of the string returned from SQL Server. With SQL Server 2000, we were seeing a length of zero ("0") returned for a NULL value. With 2005, we're getting back NULL. It tripped up some routines on the site and I thought I'd pass it along. Makes sense, but odd that it gets different treatment through ADO (directly executed SELECT statements return NULL for len(gth) as expected). We now check both length and NULL return values.
For more on SSWUG visit their web site here.
Good Day!
Ryan
MS SQL RegExpression Matching
MS SQLGood morning all, last week I was tasked with a new project at work. This project entailed taking string of characters and matching them up with an appropriate systems. The string of characters were account numbers and the systems were billing systems. See here at the company I work for we have hundreds if not thousands of different looking account numbers. Here are an example of just a few.
0652849190293
517M394586
313E880350350
178668
IIRSLUXW
NV300083
205SWTA280100A2800000
1788555400001
AL0000000000011999716
Now the reason we have so many different type of account numbers is beside the point. Things like this just happen when you work in an industry that is ripe for spin-offs and consolidations. However what this post is about is Regular Expressions!!! Not just regular expressions in CF, but regular Expressions on MS SQL server. A quick Google search for “MS Regular Expressions” led me to “The Code Project” site and to this article and download. In the article is a zip file containing four extended stored procedures to be loaded in the master DB of your MS SQL server. These four procedures; xp_regex_match, xp_regex_format, xp_regex_split and xp_regex_replace are very easy to load and use. In no time I had downloaded the file and created the procedures on my server for use.
So with these procedures in place I wrote a simple form in ColdFusion that allows a user to input a single value for an account number. ColdFusion then calls the procedure below which loops over a series of Regular Expression statements stored in a table. If the account number matched that result is saved in a list then the details are sent back to the user.
Pretty cool stuff if you ask me. And there really is no better way to learn more about Regular Expressions than to have to write 177 different expressions to match possible account numbers. And I've only begun to scratch the surface.
Good Day!
Ryan
MS SQL SP_HELP
MS SQLTodd over at <cfsilence > blogged today about SP_HELP. I did not know this stored proc existed but apparently you can run it on any sort of object in your database and it will provide information on that object.
For example I ran:
EXEC sp_help TEAccount
After executing this SP on my table in query analyzer I got 7 result sets returned. The record sets tell you everything about the table, when it was created and by whom. It lists all of the columns in the table, any identity fields, as well as any index information. Give it a shot!
Thanks for the post Todd , keep on keepin on!
Good Day!
Ryan
SQL Joins
MS SQLA post on <cfsilence> today got me think of joins and the right vs wrong way to do things.
When doing an SQL inner join is it best to have something like
SELECT a.someThing1,a.someThing2
b.someThing1,b.someThing2
FROM someTable1 a INNER JOIN
someTable2 b ON a.someKey1 = b.someKey1
or something like this
SELECT a.someThing1,a.someThing2
b.someThing1,b.someThing2
FROM someTable1 a,
someTable2 b
WHERE a.someKey1 = b.someKey1
Notice the join is in the from statment in first example vs the where statement in the second example. Is there a difference betweent the two? Is one better than the other? How do you do it? How do you roll?
Good Day!
Ryan





Loading....