Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Decimal to Binary

Posted on 2012-04-11
3
Medium Priority
?
323 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
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…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

877 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