Search
Blogland
Author: host Created: 7/22/2007 6:21 PM
This professional blog focuses on SQL Server and related activities in Indianapolis

Joining Table-Valued Functions
By host on 5/29/2008 8:28 AM

In a relational database the use of JOIN is invaluable when combining data in one table to another. Through stored procedures the ability to use JOIN to combine physical tables to views, temporary tables, derived tables and table variables is equally important in our realm of data retrieval activities.

In SQL Server 2000, the table-valued function was introduced. The table-valued function provides a user defined function the ability to return a table object. The ability to combine the results of a table-valued function has been available through the use of JOIN; but presented some challenges when the argument that is to be passed is a value that changes for each record of the parent table. The following statement will result in a syntax error:

    SELECT
&nbs ...

More...

The Hidden Aspects of ISNUMERIC
By host on 5/19/2008 8:53 PM
SQL Server 2005 Books Online describes the ISNUMERIC function as: “ISNUMERIC returns 1 when the input expression evaluates to a valid integer, floating point number, money or decimal type; otherwise it returns 0. A return value of 1 indicates that expression can be converted to at least one of the numeric types.

To illustrate this, the following statement will return the value of 1 (true):

SELECT ISNUMERIC('486')

While the following statement will return the value of 0 (false):

SELECT ISNUMERIC('ABC')

There are some additional characters that return a positive response to the function that are not regularly considered numeric such as the dollar sign (“$”), the comma (“,”) and the period (“.”). This occurs since they can be converted into other numeric data types. For example, the following statement ...
More...

Thoughts on Writing
By host on 5/11/2008 8:51 PM
Last week, Steve Jones editor of SQL Server Central, wrote an editorial on the subject of writing. That subject was the catalyst for numerous responses in the associated forum topic – including one from yours truly. The responses were very interesting. Some responses spoke about how the irony of life has turned adolescent anti-writers into adult professional writers. Others lamented about wanting to write but not having the confidence to put finger to key for the purpose of prose. Others also stated that other priorities did not leave enough time in the day to apply their writing skills. Finally, there were those who squelched the pen in fear of peer criticism.

This great spurt of ...
More...

A Wrinkle in Time is Revealed
By host on 5/5/2008 9:08 PM

If date and time precision is important to you, an odd experience may be waiting for your discovery.  No, it is not a wrinkle in time it is the rounding of milliseconds in the datetime data type.

According to SQL Server 2000 Books On Line (BOL), the DateTime data type is described as follows:
Date and time data from January 1, 1753 through December 31, 9999, to an accuracy of one three-hundredth of a second (equivalent to 3.33 milliseconds or 0.00333 seconds). Values are rounded to increments of .000, .003, or .007 seconds, as shown in the table.

Below is a series of data entries into a table that illustrate the affect of the millisecond rounding. The value on the left is the date and time value captured in a varchar data type which reflects the actual value that was submitted to the database. The value on the right is the date and time value captured in a datetime datatype that reflects the millisecond rounding that is described by BOL.< ...

More...

A Study on Dynamic SQL: The Article
By host on 5/2/2008 3:34 PM
As noted in my previous blog regarding Indy Code Camp; I have authored a supporting article of the same topic in which I presented at the code camp. This article is available in the downloads section of my site, or you can click here to download the article.

Making Choices Through Analysis
By host on 4/30/2008 10:11 AM

As we work with other Professionals in our industry, we quickly learn that there are many ways to accomplish a given task. When presented with multiple options in a situation, there are times where one option stands out as the optimal choice based upon our general knowledge of the database engine. There are also times where the optimal choice may not be so obvious and will vary depending on many considerations such as database architecture, level of use, indexing, hardware configuration or general best practices. Any given approach may perform superbly with one database and drag on another.

A sample case might be that we are given two versions of a seemingly simple query that filters the data. One option is the common use of a WHERE clause. The other is utilizing the filters within the JOIN clause. The examples below illustrate the syntax differences between these options.

WHERE Filter Option< ...

More...

IndyCodeCamp: Indy Rocks!!
By host on 4/26/2008 11:27 AM
On April 26th, I presented a session at IndyCodeCamp with the title of “A Study of Dynamic SQL”. For source code used in this presentation, go to the Downloads page of this site. Majority of those in attendance at the camp were primarily .NET Developers rather than SQL Developers which was ideal since it fit my target audience for my session.

IndyCodeCamp was a great opportunity to learn and share with 24 sessions from “Office 2007 Development with VS 2008" (presented by Bill Steele) to “Silverlight – Your LINQ to Better Experience” (presented by Chad Campbell) to “ASP.NET Performance and Optimization” (presented by Jeff McWherter) all at a very ...
More...

Common Table Expressions
By host on 4/21/2008 6:42 AM

In my previous blog entries I have spoken about temporary tables, table variables and derived tables when building stored procedures. All of these are useful features of SQL Server. When SQL Server 2005 was released another feature was added that joins in this happy family of temporary datasets: Common Table Expressions (CTE).

The syntax of a CTE is:
    
    WITH [CTE Name] ([Columns To Return]) AS ([SQL Statement);

A sample of this syntax is:

    USE [AdventureWorks];

    WITH myCTE (
              [AddressID],
   &a ...

More...

Pretty Sneaky SSIS
By host on 4/14/2008 6:46 AM
I have developed a plethora of data transformation services (DTS) packages in the past. I find DTS packages to be very powerful and handy for building scheduled interfaces between data sources. Despite working with SQL Server 2005 since its introduction I had not had the opportunity to dabble with SQL Server Integration Services (SSIS) until very recently.

The task set before was to transform data from a SQL Server 2000 database into a fixed length multi segmented flat file. The unique characteristics of a multi-segmented file are that a single record is represented with multiple rows of data within the flat file. Not all records may have the same number of rows. Below is a brief example of a multi-segmented flat file containing a header row and a single data record (all data in the file is fictional):

29800000000000000000000000SB00001BKH00000002712007011420070215
2980000100000000001234SB00000001BOX0000000300001000044H120040412200404120
More...

A Thought on Data Confidentiality
By host on 4/6/2008 9:35 PM
Data confidentiality is a key aspect in database security. Data integrity and Data availability are also important aspects; but the consequences of sensitive data being disclosed have broad consequences. Discussions regarding data confidentiality often focus on unauthorized persons who compromise other security efforts or impersonate a valid user; but, the highest probability of disclosure of sensitive data occurs with the person who sits within the office and has authorized access to the data.

No one wants to think that the person sitting in the next cubicle is an identity thief. The purposes of using the sensitive information may not even reach the level of identity theft; but that information can be used to gain some knowledge about their neighbor that is passed around the rumor mill. Another situation could even be that your fellow cubicle dweller is gathering information about a local celebrity that is sold to the press. (
More...

Copyright 2007 John Magnabosco