Select Records Issue

  • Use SSIS and Excel 2007+.

    Now please answer the 'TOP' question. I'll spell it out.

    Assume you have 10 companies

    Company1, Company2, ..., Company10

    The first time you run

    SELECT TOP 3 Company from Company

    you might get Company1, Company2, Company3 returned.

    The second time, you might get

    Company5, Company6, Company10

    That is what is puzzling everyone.


  • Thank u for ur reply

    For SELECT TOP 3 issue...i am not concern to pick specific 3 companies...any 3 may be from these 10 companies...i mean may be company 1,2,3 or 4,5,6...as all these companies are paid.....i resolved this issue by my query i mentioned earlier.....

    For Excel issue please let me check your sugestions

  • @SSCrazy

    Hi,

    the below procedure works for me for less amount of data....when i increased the number of data from 100000....now this do not give me result...the server is executing for more than 7 minutes and do not return anything...due to which my application return server timeout error.....can you please give me a replaceable code for this SP,which works like this

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[GetBDResults]

    @scat INT,

    @loc nvarchar(100)

    AS

    BEGIN

    SELECT top 100 ID, COMPANY,

    ADDRESS, Area, POSTALCODE, PROVINCE, PHONE1,

    FAX, EMAIL, WEBSITE , city, lat, lon

    FROM vwSearchResult

    WHERE scatID = @SCAT AND city like '%'+@loc+'%' AND ID IN (

    SELECT TOP 3 ID

    FROM vwSearchResult

    WHERE scatID = @SCAT AND city like '%'+@loc+'%' AND FLAG = 1 )

    OR

    ID IN (SELECT TOP 100 ID

    FROM vwSearchResult

    WHERE scatID = @SCAT AND city like '%'+@loc+'%' AND FLAG = 0 )

    END

Viewing 3 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply