Suraj Binorkar Suraj Binorkar - 1 year ago 78
SQL Question

Why I am getting this Error : "columname is not a defined system type" in SQL Server 2008?

I wanted to check the records from back 10 days to current date when I was trying to run this query:

select top 1 *
from tbl_refrence_master
where ref_id='4110118488'
and CONVERT(date, ref_entry_date) between DATEADD(day, -10, convert(ref_entry_date, GETDATE()))
and CONVERT(date, getdate())

But I'm getting this error:

Type ref_entry_date is not a defined system type.

I can do the same through my source code but I wanted to do by this SQL query.
Why I am getting this error?

Answer Source
SELECT top 1 * 
FROM tbl_refrence_master 
WHERE ref_id='4110118488'
    AND ISDATE(ref_entry_date) = 1 
    AND DATEDIFF(d,ref_entry_date,GETDATE()) BETWEEN 0 AND 10
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download