Solved

Decimal to Binary

Posted on 2012-04-11
3
315 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)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

772 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