• Please see Gail's post about how to post performance problems here. http://www.sqlservercentral.com/articles/SQLServerCentral/66909/[/url]

    I would make two recommendations about your query. First you should NEVER use select * in a production environment. Secondly you should use column names in your order by instead of ordinal position. Of course as you say there is only 1 row that meets the where condition so why do you even bother to order a result set of 1?

    I also have to question some of your datatypes. You have a column named access_date_time which indicates it will a datetime value but the datatype is varchar(max). If this is really date information you should the appropriate datatype.

    Also, you have a number of columns like sid_ids. The names indicate this is holding a delimited list of values. This type of thing should be normalized instead crammed into a single column. It makes it a lot harder to work with.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/