SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


No Results from Query - SQL Server 2012


No Results from Query - SQL Server 2012

Author
Message
et2brutuss
et2brutuss
SSC-Enthusiastic
SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)

Group: General Forum Members
Points: 152 Visits: 45
I have written a relatively simple query but it generating zero results. I am not getting any error message, just no results. On the messages tab it says '0 rows affected'.
Here is the query:
use CLL_LIVE
go
SELECT Em.Empno
,RTRIM (em.GivenName)
,RTRIM (em.Surname)
,em.Position
,em.EMail
,p.Rate
FROM Employee_Master AS em
JOIN PayDetail AS p
on em.Empno = p.Empno
WHERE em.EmployStatus <> 11

It is pretty basic, Employee Id, Name, Position, Email and pay rate. As long as there is no join and the "rate" is not asked for it generates a list of all employees. Once I join the paydetail table, I get no results.
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11702 Visits: 37453
what datatype is "em.EmployStatus "?

________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91032 Visits: 38945
et2brutuss (8/11/2014)
I have written a relatively simple query but it generating zero results. I am not getting any error message, just no results. On the messages tab it says '0 rows affected'.
Here is the query:
use CLL_LIVE
go
SELECT Em.Empno
,RTRIM (em.GivenName)
,RTRIM (em.Surname)
,em.Position
,em.EMail
,p.Rate
FROM Employee_Master AS em
JOIN PayDetail AS p
on em.Empno = p.Empno
WHERE em.EmployStatus <> 11

It is pretty basic, Employee Id, Name, Position, Email and pay rate. As long as there is no join and the "rate" is not asked for it generates a list of all employees. Once I join the paydetail table, I get no results.


Query the PayDetail table and verify that the Empno values in this table exists in the Employee_Master table.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
et2brutuss
et2brutuss
SSC-Enthusiastic
SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)

Group: General Forum Members
Points: 152 Visits: 45
The whole query has char as the data type with the exception of 'rate' which is decimal
et2brutuss
et2brutuss
SSC-Enthusiastic
SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)

Group: General Forum Members
Points: 152 Visits: 45
That resolves the problem, the values I am looking for don't exist in the PayDetail table.. Thank you for your assistance.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search