Click here to Skip to main content
15,886,518 members
Home / Discussions / Database
   

Database

 
QuestionRe: Show Statement Pin
Eddy Vluggen23-Jun-11 9:14
professionalEddy Vluggen23-Jun-11 9:14 
QuestionSQL Jobs Output Pin
Groulien23-Jun-11 4:05
Groulien23-Jun-11 4:05 
AnswerRe: SQL Jobs Output [modified] Pin
UNCRushFan23-Jun-11 7:30
UNCRushFan23-Jun-11 7:30 
GeneralRe: SQL Jobs Output Pin
Groulien23-Jun-11 22:56
Groulien23-Jun-11 22:56 
Questionis these two queries same? Pin
Dhyanga23-Jun-11 3:08
Dhyanga23-Jun-11 3:08 
AnswerRe: is these two queries same? Pin
JV999923-Jun-11 3:44
professionalJV999923-Jun-11 3:44 
GeneralRe: is these two queries same? Pin
Dhyanga23-Jun-11 3:53
Dhyanga23-Jun-11 3:53 
Questionproblem trying to use UNION in the sql query Pin
Dhyanga23-Jun-11 3:03
Dhyanga23-Jun-11 3:03 
Hi all,

I have two sets of query which if run alone, runs without any errors but when i try to use UNION between these two queries, it gave me error like this:
Error converting data type varchar to numeric.

The sql queries are
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
                        a.RESIDSTS, d.ROOM_DESC, d.ROOM_PHONE
                        from SMASTER a 
                        join NMASTER b on a.ID_NUM = b.ID_NUM
                        join BMASTER c on a.ID_NUM = c.ID_NUM
                        join RMASTER d on a.LOC_CDE = d.LOC_CDE and a.BLDG_CDE = d.BLDG_CDE and a.ROOM_CDE = d.ROOM_CDE
                        where LOWER(b.LAST_NAME) like '%ram%'
                        and a.RESIDSTS = 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))
 UNION 
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
                        a.RESIDSTS as STATUS, '' , '' 
                        from SMASTER a 
                        join NMASTER b on a.ID_NUM = b.ID_NUM
                        join BMASTER c on a.ID_NUM = c.ID_NUM
						join RMASTER d on a.ID_NUM = a.ID_NUM
                        where LOWER(b.LAST_NAME) like '%ram%'
                        and a.RESIDSTS <> 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))



but when i run
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
                        a.RESIDSTS, d.ROOM_DESC, d.ROOM_PHONE
                        from SMASTER a 
                        join NMASTER b on a.ID_NUM = b.ID_NUM
                        join BMASTER c on a.ID_NUM = c.ID_NUM
                        join RMASTER d on a.LOC_CDE = d.LOC_CDE and a.BLDG_CDE = d.BLDG_CDE and a.ROOM_CDE = d.ROOM_CDE
                        where LOWER(b.LAST_NAME) like '%ram%'
                        and a.RESIDSTS = 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))


or
select a.ID_NUM as ID, b.LAST_NAME, b.FIRST_NAME, c.BIRTH_DTE, RIGHT(c.SSN, 4),
                        a.RESIDSTS as STATUS, '' , '' 
                        from SMASTER a 
                        join NMASTER b on a.ID_NUM = b.ID_NUM
                        join BMASTER c on a.ID_NUM = c.ID_NUM
						join RMASTER d on a.ID_NUM = a.ID_NUM
                        where LOWER(b.LAST_NAME) like '%ram%'
                        and a.RESIDSTS <> 'R' and (a.T_CDE in ('20', '21') or a.UDEF in ('20', '21'))

it runs.

Can anyone help me solve this out?
suchita

AnswerRe: problem trying to use UNION in the sql query Pin
Dhyanga23-Jun-11 4:04
Dhyanga23-Jun-11 4:04 
AnswerRe: problem trying to use UNION in the sql query Pin
Chris Meech23-Jun-11 4:16
Chris Meech23-Jun-11 4:16 
QuestionMySqlDBType equivalent of SqlDBType.Char in routines (stored procedures) Pin
TheComputerMan22-Jun-11 0:57
TheComputerMan22-Jun-11 0:57 
AnswerRe: MySqlDBType equivalent of SqlDBType.Char in routines (stored procedures) Pin
Mycroft Holmes23-Jun-11 11:59
professionalMycroft Holmes23-Jun-11 11:59 
GeneralRe: MySqlDBType equivalent of SqlDBType.Char in routines (stored procedures) Pin
TheComputerMan23-Jun-11 22:15
TheComputerMan23-Jun-11 22:15 
GeneralRe: MySqlDBType equivalent of SqlDBType.Char in routines (stored procedures) Pin
Mycroft Holmes23-Jun-11 22:24
professionalMycroft Holmes23-Jun-11 22:24 
GeneralRe: MySqlDBType equivalent of SqlDBType.Char in routines (stored procedures) Pin
TheComputerMan23-Jun-11 22:57
TheComputerMan23-Jun-11 22:57 
QuestionLookup Columns In Access via Linked Data? Pin
Matt U.21-Jun-11 11:41
Matt U.21-Jun-11 11:41 
AnswerRe: Lookup Columns In Access via Linked Data? Pin
_Damian S_21-Jun-11 14:34
professional_Damian S_21-Jun-11 14:34 
GeneralRe: Lookup Columns In Access via Linked Data? Pin
Matt U.21-Jun-11 14:48
Matt U.21-Jun-11 14:48 
GeneralRe: Lookup Columns In Access via Linked Data? Pin
_Damian S_21-Jun-11 14:52
professional_Damian S_21-Jun-11 14:52 
GeneralRe: Lookup Columns In Access via Linked Data? Pin
Matt U.21-Jun-11 15:04
Matt U.21-Jun-11 15:04 
GeneralRe: Lookup Columns In Access via Linked Data? Pin
Mycroft Holmes21-Jun-11 18:36
professionalMycroft Holmes21-Jun-11 18:36 
AnswerRe: Lookup Columns In Access via Linked Data? Pin
Mycroft Holmes21-Jun-11 18:41
professionalMycroft Holmes21-Jun-11 18:41 
GeneralRe: Lookup Columns In Access via Linked Data? Pin
Matt U.24-Jun-11 16:40
Matt U.24-Jun-11 16:40 
GeneralRe: Lookup Columns In Access via Linked Data? Pin
Mycroft Holmes24-Jun-11 21:17
professionalMycroft Holmes24-Jun-11 21:17 
GeneralRe: Lookup Columns In Access via Linked Data? Pin
Matt U.25-Jun-11 1:44
Matt U.25-Jun-11 1:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.