Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
function
Starting Member
12 Posts |
Posted - 2009-11-23 : 07:53:46
|
Hi guys, I have 2 tables as follows:
FIRST TABLE: =============== firsttable_id, perigrafi_id (coming from another table), first_decode
SECOND TABLE: =============== secondtable_id, perigrafi_id (the same as above), second_encode
All i want to do is a union statement as follows:
SELECT '' as [first_encode] from firsttable where perigrafi_id=1 union SELECT second_encode from secondtable where perigrafi_id=1
But the result is like this: ============================= 0 1
instead of '' (empty space quote) 1 How can i achieve the second result with a case statement?
Thanks in advance!
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-23 : 08:21:51
|
It is the formation issues.Just return as such but suppress in .NET
or
SELECT '' as [first_encode] from firsttable where perigrafi_id=1 union SELECT cast(second_encode as varchar(10)) from secondtable where perigrafi_id=1
Madhivanan
Failing to plan is Planning to fail |
 |
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-11-23 : 08:30:45
|
Hi function
SELECT statement within the UNION must have the same number of columns and must also have the similar data types.
------------------------- R... |
 |
|
function
Starting Member
12 Posts |
Posted - 2009-11-23 : 08:38:14
|
Thank you all guys. It worked like a charm! |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|