Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Null valus in a select
How do I check of null in a select clause and replace them with space/empty
string?

Report this thread to moderator Post Follow-up to this message
Old Post
Arne
11-29-05 04:23 PM


Re: Null valus in a select
SELECT COALESCE(col_x, '') AS col_x
FROM your_table ;

--
David Portas
SQL Server MVP
--


Report this thread to moderator Post Follow-up to this message
Old Post
David Portas
11-29-05 04:23 PM


Re: Null valus in a select
David Portas  wrote:
> SELECT COALESCE(col_x, '') AS col_x
>  FROM your_table ;

or

SELECT ISNULL(col_x, '') AS col_x
FROM your_table

robert


Report this thread to moderator Post Follow-up to this message
Old Post
Robert Klemme
11-29-05 04:23 PM


Re: Null valus in a select
That kind of works, except if the column is a smallint I get 0 instead of ''

"David Portas" wrote:

> SELECT COALESCE(col_x, '') AS col_x
>  FROM your_table ;
>
> --
> David Portas
> SQL Server MVP
> --
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Arne
11-29-05 04:23 PM


Re: Null valus in a select
That kind of works, except if the column is a smallint I get 0 instead of ''



"Robert Klemme" wrote:

> David Portas wrote: 
>
> or
>
> SELECT ISNULL(col_x, '') AS col_x
>  FROM your_table
>
>     robert
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Arne
11-29-05 06:23 PM


Re: Null valus in a select
Arne,

An expression in the Selection List can only return the predefined data
type. If you want to return a smallint, then by definition, you cannot
return an empty string. If returning a string works for you, then you
can use this:

SELECT COALESCE(CAST(col_x AS VARCHAR(11)), '') AS col_x
FROM your_table

Gert-Jan


Arne  wrote:[color=darkred
]
>
> That kind of works, except if the column is a smallint I get 0 instead of 
''
>
> "Robert Klemme" wrote:
> 

Report this thread to moderator Post Follow-up to this message
Old Post
Gert-Jan Strik
11-30-05 01:23 AM


Re: Null valus in a select
Try this.

SELECT  ISNULL(CONVERT(VARCH
AR(5),col_x), '') AS col_x  FROM your_table

"Arne" wrote:

> That kind of works, except if the column is a smallint I get 0 instead of 
''
>
>
>
> "Robert Klemme" wrote:
> 

Report this thread to moderator Post Follow-up to this message
Old Post
S
11-30-05 01:23 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 11:16 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006