DarrenJackson
asked on
max statment in sql 2008 not working
Guys
I am trying to do a max statement on the following t-sql
it errors with msg
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
the field diary.updatedonx that is getting maxed is originally in seconds and im converting it to a date time and now want to just return the lastest line
Any ideas
Regards
I am trying to do a max statement on the following t-sql
select
udb.fk_cmdb_id,
udb.ad_login,
udb.fullname,
udb.firstname,
udb.surname,
udb.job_title,
udb.department,
udb.mobiletel,
udb.faxtel,
udb.email,
udb.user4,
udb.location,
udb.site,
udb.postcode,
udb.telext,
udb.fk_company_id,
udb.companyname,
udb.fk_manager,
udb.status,
cmdb.ck_config_item,
cmdb.ck_config_type,
cmdb.cmdb_status,
cmdb.fk_status_level,
cmdb.fk_userdb,
cmdb.pk_auto_id,
max((convert(varchar, DATEADD(second, diary.updatedonx, '19700101') ,121))) as date1 ,
diary.updatetxt,
diary.analystid,
diary.udcode,
diary.udsource,
diary.fk_ci_id,
diary.pk_auto_id
from
config_itemi cmdb,
userdb udb,
config_diary diary
where
cmdb.fk_userdb = udb.keysearch
and cmdb.pk_auto_id = diary.fk_ci_id
and cmdb.ck_config_type like 'HARDWARE%'
group by
udb.fk_cmdb_id,
udb.ad_login,
udb.fullname,
udb.firstname,
udb.surname,
udb.job_title,
udb.department,
udb.mobiletel,
udb.faxtel,
udb.email,
udb.user4,
udb.location,
udb.site,
udb.postcode,
udb.telext,
udb.fk_company_id,
udb.companyname,
udb.fk_manager,
udb.status,
cmdb.ck_config_item,
cmdb.ck_config_type,
cmdb.cmdb_status,
cmdb.fk_status_level,
cmdb.fk_userdb,
cmdb.pk_auto_id,
diary.updatetxt,
diary.analystid,
diary.udcode,
diary.udsource,
diary.fk_ci_id,
diary.pk_auto_id
it errors with msg
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
the field diary.updatedonx that is getting maxed is originally in seconds and im converting it to a date time and now want to just return the lastest line
Any ideas
Regards
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks