Forum Replies Created

Viewing 15 posts - 16 through 30 (of 149 total)

  • RE: Query getting MAX value of each GROUP of values

    Glad I could help. It is always helpful to have another set of eyes look at things.

    Dave

  • RE: Query getting MAX value of each GROUP of values

    Try this:

    SELECT pStart, MAX(txnDate) AS txnDate

    FROM Period p INNER JOIN TXN t ON p.[Key] = t.[Key]

    GROUP BY pStart

    Dave Novak

  • RE: Get rid of Dynamic SQL

    Try this:

    CREATE PROCEDURE p_Get_Filtered (

    @LineFilter varchar(50),

    @StatusFilter varchar(50),

    @MTDGreaterThan decimal(15,2),

    @MTDLessThan decimal(15,2),

    @QTDGreaterThan decimal(15,2),

    @QTDLessThan decimal(15,2),

    @AchieveLevelStart int,

    @AchieveLevelEnd int)

    SET NOCOUNT ON

    DECLARE @LineTable table (Line int)

    DECLARE @MTDGreater decimal(15,2),

    @MTDLess decimal(15,2),

    @QTDGreater decimal(15,2),

    @QTDLess decimal(15,2)

    --Code to build temp table #DLFiltered goes...

  • RE: Contacts table and preferred addresses

    Give this a try:

    SELECT PersonId,

    CASE WHEN c.EmailId = -1 THEN e.EmailAddress ELSE NULL END AS PreferredEmail,

    CASE WHEN c.PostalAddressId = -1 THEN p.Address ELSE NULL END AS PreferredAddress

    FROM tContacts c

    LEFT JOIN...

  • RE: how to gather backup information on remote servers

    For these situations, I use one central SQL Server as a repository for the info from all the other servers. Since you have SQL Server 2005, I would use...

  • RE: Update Variable Number of Rows

    What Steve is saying is the the 'SET ROWCOUNT' command while achieve what you want to do.

    Here is an example using your situation:

    DECLARE @NumRecs int, @Value varchar(25)

    SET @NumRecs = 100

    SET...

  • RE: TEMP Tables

    What is being passed into the variable '@LineFilter' that it is ignore the final else?

  • RE: back ups

    Indirectly, yes it is possible to restore just one table.

    Directly, no you can not restore just one table from a database.

    Indirectly, you restore the database as a different name or...

  • RE: TEMP Tables

    You need to use 'IF .. ELSE IF ... ELSE IF ... ELSE'

    IF @LineFilter = ('Only Line 1')

    ...

  • RE: TEMP Tables

    Try this:

    IF @LineFilter = ('Only Line 1')

    BEGIN

    (SELECT * FROM #DLFiltered

    WHERE Active = 1

    AND...

  • RE: TEMP Tables

    Make the IF statement as follows:

    IF @LineFilter = ('Only Line 1')

    AND EXISTS (SELECT NULL FROM .... WHERE .......)

    BEGIN {Insert statement and select statement}

    ...

  • RE: TEMP Tables

    GSquared is right, the if exists clause is better.

    this would look like this:

    IF EXISTS (SELECT NULL FROM #DLFiltered

    WHERE Active = 1

    AND DownlineLevel = 1

    ...

  • RE: [?]..sysfiles.size Question

    If you are trying to breakdown the size field of the SYSFILES system table to GB, here is a breakdown of how to do it.

    The size column is the number...

  • RE: a variable name manipulation

    Good luck. Let me know if you need any help.

    Dave Novak

  • RE: TEMP Tables

    Art,

    IF @LineFilter = ('Only Line 1')

    SELECT * from #DLFiltered WHERE Active = 1

    ...

Viewing 15 posts - 16 through 30 (of 149 total)