Solved

numeric (NULL/Blank) > Text

Posted on 2009-07-15
2
362 Views
Last Modified: 2012-08-14
Hi Experts,

Need to convert numeric to text such that if NULL or blank it takes up a space

This works if @int is NOT:

SET @int = NULL
SET @int = ''

SELECT coalesce(convert(varchar(10), @int),'')

TIA!
0
Comment
Question by:allanau20
[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 Comments
 
LVL 18

Accepted Solution

by:
philipjonathan earned 250 total points
ID: 24865792
To handle when int is NULL, insert a space in between the last argument:
SELECT coalesce(convert(varchar(10), @int),' ')

If @int is numeric type, it couldn't be ' ', so you don't need to worry about that
0
 
LVL 5

Author Comment

by:allanau20
ID: 24872653
Thanks -- just need to tweak it abit.

SELECT coalesce(convert(CHAR(10), @int), SPACE(10))
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
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…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

752 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