Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

No Results from Query - SQL Server 2012 Expand / Collapse
Author
Message
Posted Monday, August 11, 2014 10:33 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, October 8, 2014 6:23 AM
Points: 16, Visits: 44
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.
Post #1601955
Posted Monday, August 11, 2014 10:47 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:16 PM
Points: 1,943, Visits: 20,185
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
Post #1601958
Posted Monday, August 11, 2014 10:48 AM This worked for the OP Answer marked as solution


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 2:40 PM
Points: 20,863, Visits: 32,901
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.



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)
Post #1601959
Posted Monday, August 11, 2014 11:01 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, October 8, 2014 6:23 AM
Points: 16, Visits: 44
The whole query has char as the data type with the exception of 'rate' which is decimal
Post #1601968
Posted Monday, August 11, 2014 11:17 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, October 8, 2014 6:23 AM
Points: 16, Visits: 44
That resolves the problem, the values I am looking for don't exist in the PayDetail table.. Thank you for your assistance.
Post #1601982
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse