Home Forums SQL Server 2008 SQL Server Newbies Need Help with the Error 'Subquery returned more than 1 value'. RE: Need Help with the Error 'Subquery returned more than 1 value'.

  • Grass (4/15/2012)


    I tried using before but didn't work.can u tell me how to use the distinct to replace SET statement.what fields needs to be distinct?

    thanks.

    Try these for Distinct:

    SET @Project_ID = (SELECT Distinct project_id FROM int_aux_project WHERE [/img]project_cd = @Matter_ID)

    SET @Project_Desc = (SELECT Distinct project_nm FROM int_aux_project WHERE project_cd = @Matter_ID)

    SET @Listing_ID = (SELECT Distinct listing_id FROM int_aux_lst_custom WHERE string_value = @Billing_ID AND LST_CUSTOM_DEF_ID = '-10017')

    SET @User_ID= (SELECT Distinct user_id FROM int_user WHERE listing_id = @Listing_ID)

    If Distinct doesn't work, try these for Select 1:

    SET @Project_ID = (SELECT Top 1 project_id FROM int_aux_project WHERE [/img]project_cd = @Matter_ID)

    SET @Project_Desc = (SELECT Top 1 project_nm FROM int_aux_project WHERE project_cd = @Matter_ID)

    SET @Listing_ID = (SELECT Top 1 listing_id FROM int_aux_lst_custom WHERE string_value = @Billing_ID AND LST_CUSTOM_DEF_ID = '-10017')

    SET @User_ID= (SELECT Top 1 user_id FROM int_user WHERE listing_id = @Listing_ID)

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉