I have a table in which we can have the same ticket no.for multiple entries.i I want to get the last ticket number (of the same number) based on Initiated on column.
Ticket VendorTicket InitiatedOn Comments 198165 test 2012-08-10 16:31:33.707 test 199485 sagar 2012-08-11 12:36:25.720 sagar 199485 sagar1 2012-08-11 14:36:25.720 sagar1 199478 kishor 2012-08-11 12:37:21.923 kishor
I wrote this query in T-SQL in a stored procedure. It gives me the error message xObj = {"Incorrect syntax near '.'."}
My T-SQL
`@SQL='Select ''<a href="javascript:editTicketByIDAction('' + CONVERT(VarChar(Max), Ticket) + '')">'' + CONVERT(VarChar(Max),Ticket) + ''</a>'' t1.Ticket,t1.VendorTicket[Vendor Ticket],t1.Comments From VendorTickets t1 WHERE NotifyOn <= GetDate() And NotifyOn Is Not Null AND NOT EXISTS (SELECT * FROM VendorTickets t2 WHERE t1.Ticket = t2.Ticket AND t1.InitiatedOn < t2.InitiatedOn)'`
source share