SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Help Me!!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yonkouturko
Yak Posting Veteran

Philippines
57 Posts

Posted - 09/12/2013 :  04:01:23  Show Profile  Reply with Quote
DECLARE @datetoday AS varchar(max)
set @datetoday = CONVERT(VARCHAR(10), getdate(), 111)
SELECT ReferenceNumber AS REFERENCENUMBER, DATEDIFF(D,
(SELECT TOP (1) MODIFIED_DATE
FROM Table_customer_record_expected_service
WHERE (C_ID = Table_Customer_Records.ID)
ORDER BY ID DESC), @datetoday) AS [Last Days of Transaction], Company_Name AS [COMPANY NAME], Contact_Person AS [CONTACT PERSON],
Email_Address AS EMAIL, Line_of_Business AS [LINE OF BUSINESS], Telephone_No AS TELEPHONE, Mobile_No AS MOBILE, Fax_No AS FAX, Address AS ADDRESS,
Area AS AREA, Website AS WEBSITE, Priority_Level AS PRIORITY,
(SELECT TOP (1) MODIFIED_DATE
FROM Table_customer_record_expected_service
WHERE (C_ID = Table_Customer_Records.ID)
ORDER BY ID DESC) AS [LAST DATE CALLED],
(SELECT TOP (1) DATE_RECEIVED
FROM Table_JobOrder_Information
WHERE (C_ID = Table_Customer_Records.ID)
ORDER BY ID DESC) AS [LAST DATE OF TECHNICAL SERVICE], ID
FROM Table_Customer_Records

C_ID and Table_Customer_Records.ID are both bigint...in data type....

this query error says
"Error converting data type varchar to bigint."

i don't know whats happening

James K
Flowing Fount of Yak Knowledge

3323 Posts

Posted - 09/12/2013 :  09:14:05  Show Profile  Reply with Quote
If they are indeed bigints, then it should not throw that error. Verify that it is so by running this query and a similar one for C_ID (or looking up in SSMS object explorer)
SELECT OBJECT_NAME(Object_id),c.name AS ColumName, t.name AS DataType
FROM sys.columns c  
INNER JOIN sys.types t ON t.system_type_id = c.system_type_id
WHERE OBJECT_NAME(Object_id) = 'Table_Customer_Records'
AND c.name = 'ID'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 09/12/2013 :  16:02:07  Show Profile  Reply with Quote
may be one of columns are having some nonnumeric data.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000