troubleshooting Question

SQL - Data Type Issue

Avatar of Zack
ZackFlag for Australia asked on
SQLMicrosoft SQL Server
5 Comments1 Solution16 ViewsLast Modified:
Hi EE,

I have an issue with the following query:

SELECT CAST(W.PERSONNELNUMBER AS BIGINT) AS EMPLOYEEID, pd.description as TITLE,


(select top 1 c.COMPENSATIONLEVELID from HCMJOBDETAIL as j join HCMCOMPENSATIONLEVEL as c


on c.RECID = j.COMPENSATIONLEVEL where j.JOB =  pd.Job) as GRADE,


DEPARTMENT.NAME AS DEPARTMENT,DIVISION.NAME AS DEVISION


FROM HCMWORKER AS W


JOIN


(


select wa.POSITION,convert(nvarchar(12),wa.VALIDFROM,110) as VALIDFROM,convert(nvarchar(12),wa.VALIDTO,110) as VALIDTO


,wa.WORKER from HCMPOSITIONWORKERASSIGNMENT as wa


where DATEDIFF(m,wa.ValidFrom,wa.ValidTo)>1


group by wa.POSITION,convert(nvarchar(12),wa.VALIDFROM,110) ,convert(nvarchar(12),wa.VALIDTO,110),wa.WORKER


)


AS WA ON WA.WORKER = W.RECID and WA.VALIDFROM < GETDATE() and WA.VALIDTO > GETDATE()


join


(SELECT POSITION,convert(nvarchar(12),VALIDFROM,110) as VALIDFROM,


convert(nvarchar(12),VALIDTO,110) as VALIDTO,DEPARTMENT,


JOB,[DESCRIPTION],TITLE FROM (SELECT * FROM HCMPOSITIONDETAIL as pd


where DATEDIFF(m,pd.ValidFrom,pd.ValidTo)>1


and pd.DEPARTMENT <>0 and pd.POSITION <>0 and pd.JOB <> 0) as pd


group by POSITION,convert(nvarchar(12),VALIDFROM,110),convert(nvarchar(12),VALIDTO,110),DEPARTMENT,


JOB,[DESCRIPTION],TITLE


)


as pd on pd.POSITION = WA.POSITION and pd.VALIDFROM<GETDATE() and pd.VALIDTO > GETDATE()


LEFT OUTER JOIN dbo.DIRPARTYTABLE AS department ON department.RECID = pd.DEPARTMENT AND department.INSTANCERELATIONTYPE IN (2377)


LEFT OUTER JOIN dbo.DIRPARTYTABLE AS division ON division.NAMEALIAS = department.HCMWORKER AND division.INSTANCERELATIONTYPE IN (2377)

Open in new window


Error: Msg 8114, Level 16, State 5, Line 1
Error converting data type nvarchar to bigint.

Any assistance is appreciated.

Thank you 

ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 5 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 5 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004