Forum Replies Created

Viewing 15 posts - 331 through 345 (of 621 total)

  • RE: How do I get an average of the top two values in a result set ?

    Andrew, please understand that I am not picking on you or your code, but I am trying to learn a little bit about performance, since some of the tables in...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: How do I get an average of the top two values in a result set ?

    Todd, it sounds like you are all set with Andrew's code, but I did not want to leave mine out there with a serious flaw. I have fixed it...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: How do I get an average of the top two values in a result set ?

    andrewd.smith (4/15/2009)


    Todd,

    Did you try my correlated subquery solution? I believe it gives the results you require. If you have a large number of rows in your table and performance is...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: How do I get an average of the top two values in a result set ?

    Todd, I just realized my solution will not work if there is only one instance of any MemberID. I can't test it to be sure right now, but you...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: How do I get an average of the top two values in a result set ?

    I just realized I did not address your need to exclude where the average = 4, so I added another member ID to test, where the average would be 4,...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: How do I get an average of the top two values in a result set ?

    Todd, if you can use temp tables, maybe this will work for you. It seems to work with the sample data you provided, but may have unforeseen issues with...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: Avoiding injection on stored procedure

    Michael Valentine Jones (3/18/2009)


    bitbucket (3/18/2009)


    Might I suggest:

    CREATE PROCEDURE USPDeleteAnswers

    @Id varchar(50),

    @QId varchar(100)

    AS

    DECLARE @sql nvarchar(255)

    SET @sql = 'DELETE FROM tblUserAnswer where Id = ''' + @Id + ''' and QuestionId in...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: dropping and creating a dynamic table in a Stored Proc

    shawna.fisher (4/6/2009)


    Thank you Greg! I will give this a try.

    Shawna, you might want to look at this post, before you think about using my solution. http://www.sqlservercentral.com/Forums/Topic678702-8-1.aspx. Although to...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: How to fetch User Profile using Trigger in MS SQL Server 2000

    This is nothing the functions mentioned above won't give you, but I have found these fields useful a couple of times.

    SELECT

    NT_Login = m.name,

    ...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: Nested store_proc in a loop

    It's probably something simple, but you will have to provide more information. Please read http://www.sqlservercentral.com/articles/Best+Practices/61537/ , and if you post sample data, you will probably get some help.

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: dropping and creating a dynamic table in a Stored Proc

    sfisher, I have seen this type of question asked many times, and one of the usual responses is 'do it in the app'. I tend to agree with that...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: Looping a stored procedure

    marvin.tumasar (4/1/2009)


    I want the stored procedure to move over all the records in this view to the new table.

    Marvin, can you post the DDL for the tables involved and...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: dropping and creating a dynamic table in a Stored Proc

    It seems to me that if you have multiple columns depending on the number of employees reporting to the supervisor, then if you have column 'Question' along side them, you...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: How to get top 10 records sum gropued by One colum (USERID)

    john.arnott (3/25/2009)


    *RBAR is "Row By Agonizing Row", a term coined by stand-out SSC contributor Jeff Moden. If you can, do look for a set-based solution. Perhaps a bit...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • RE: Group By statement using multiple tables

    Well, I would say you should look at your table alias's. You are using e as an alias twice. Also, the only thing you are returning in your...

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

Viewing 15 posts - 331 through 345 (of 621 total)