Solved

Decimal to Binary

Posted on 2012-04-11
3
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

615 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