Tuesday, December 17, 2013

How to: Query BIT Data Type in SQL Server and SSIS

If you have ever met problems when trying to export BIT data type columns to files or use them in SSIS, here are the tips for you.

The bit data type is an integer data type that can take a value of 1, 0, or NULL. Thus it is often used to represent Boolean type values such as Yes/No, True/False, and On/Off. However, BIT columns might be interpreted differently by different providers. When you query BIT columns in SSMS, it displays as 1 and 0 as its value. However, when you either query BIT columns in SSIS or export them to text files, it won’t be 1 or 0 any more. Below will show you some tricks to handle BIT columns.

How SSIS handle BIT columns?

In SSIS, BIT columns are interpreted as Boolean [DT_BOOL]. How to tell this?

You need right click the OLE DB Source component and choose “Show Advanced Editor”. Then click the “Input and Output Properties” Tab. Expand “Output Columns” under OLE DB Source Output. You will notice that the BIT column is Boolean type as shown below. Here column IsSHP is the BIT data type column.

bitTypeSSIS

So when you need to query BIT column, you need to directly use TRUE or FALSE. Below shows that how you can query BIT columns in the conditional split task.


bitTypeSSISv0
Note that there is no quote around true in the expression.

How to export BIT columns to files as integers in SSIS?

Solution 1: Using Derived Columns
bitTypeSSISDerivedColumn
Or if you want to store it with less storage, you can use DT_UI1 data type.
IsSHP_bit = [IsSHP] ? (DT_UI1)1 : (DT_UI1)0


Solution 2: Tweak OLE DB Source

First of all, you need to convert BIT columns in OLE DB connection manager from OLE DB Source Editor,
select convert(int, IsSHP) as IsSHP

Then change the DataType in the OLE DB Source to integer type DT_I4 as shown below.


bitTypeSSIS2
Now you will get 1 or 0 as output for BIT columns.


That’s it and hope it will help!

Tuesday, December 10, 2013

Earn Certificates to Differentiate Yourself?

Becoming a certified DBA/developer won’t make you an exceptional DBA/developer ; being an exceptional DBA/developer doesn’t require any certification. But certifications can definitely add a plus if you have another competitor with the same other qualifications but without certifications. Below is the info about Microsoft SQL Server certifications for recent versions of SQL Server.

SQL Server 2012 related certifications

Microsoft Certified Solutions Associate (MCSA)

MCSA: SQL Server 2012 certification. It requires to pass three exams:

  1. Exam 70-461: Querying Microsoft SQL Server 2012
  2. Exam 70-462: Administering Microsoft SQL Server 2012 Databases
  3. Exam 70-463: Implementing a Data Warehouse with Microsoft SQL Server 2012

Microsoft Certified Solutions Expert (MCSE)

There are two paths for expert level certificates. The prerequisite for taking expert level exams is to earn the above MCSA.

MCSE: Data Platform

  1. Exam 70-464: Developing Microsoft SQL Server 2012 Databases
  2. Exam 70-465: Designing Database Solutions for SQL Server 2012

MCSE: Business Intelligence

  1. Exam 70-466: Implementing Data Models and Reports with Microsoft SQL Server 2012
  2. Exam 70-467: Designing Business Intelligence Solutions with Microsoft SQL Server 2012

What will be the impact of SQL Server 2014?

From the article: How will the updates for SQL Server 2014 impact official Microsoft training and certifications? It seems that SQL Server 2014 won’t affect MCSA for now but it will definitely impact MCSE exams taken after 2014 March. So if you want to complete your expert level exam for SQL Server 2012, please be sure to finish it by March.

Reference: Microsoft SQL Server certifications

Friday, December 6, 2013

SSIS Validation Status “VS_NEEDSNEWMETADATA”

Problem                                                 SSISdebug

Here is the error message:                                                   

Error on Component:[DFT_xxx]: "component "OLE DB Destination" (2327)" failed validation and returned validation status "VS_NEEDSNEWMETADATA".

It looks like some data mapping for columns in the SSIS package were lost after being deployed to the production. Both dev and production have the same number of columns. Also the name looks the same!

Solution

Check the columns to see whether they have the same case in the production as in the development. SSIS is CASE sensitive and it cannot automatically recognize those columns if the only difference is the case.

How to update column name?

You need to use sp_RENAME to update column name as below.

sp_RENAME '[dbo].[tableName].columnname', 'ColumnName' , 'COLUMN'
GO

Hope it will help you debug faster!