Solved

Decimal to Binary

Posted on 2012-04-11
3
311 Views
Last Modified: 2012-06-21
I have a SSIS package that I have a field that is a Decimal now but it needs to be converted to a binary string for example.  One of the values is 152  and that should actual after it is converted look like 10011000.  I have had it figured out in an access database by using my own module,  But now we have ported over to SQL and i need  this to be done in SSIS.  Please help.
0
Comment
Question by:Brickwall
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
yawkey13 earned 500 total points
ID: 37835824
CREATE FUNCTION udf_bin_me (@IncomingNumber int)
RETURNS varchar(200)
as
BEGIN
 
      DECLARE @BinNumber      VARCHAR(200)
      SET @BinNumber = ''
 
      WHILE @IncomingNumber <> 0
      BEGIN
            SET @BinNumber = SUBSTRING('0123456789', (@IncomingNumber % 2) + 1, 1) + @BinNumber
            SET @IncomingNumber = @IncomingNumber / 2
      END
 
      RETURN @BinNumber
 
END
0
 
LVL 6

Expert Comment

by:yawkey13
ID: 37835829
I got this function a while ago from the MSDN forums.
0
 

Author Comment

by:Brickwall
ID: 37835896
how o i incorporate this into my SIS package?
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now