Forum Replies Created

Viewing 7 posts - 1 through 7 (of 7 total)

  • RE: return a row (with constants) even if query comes up blank

    You can build up a table (table variable) with your hard-coded values, parameters or whatever:

    DROP TABLE MyTable

    CREATE TABLE MyTable (

    PersonIdint,

    FullNamevarchar(30),

    Address1varchar(50)

    )

    GO

    INSERT MyTable (

    PersonId,

    FullName,

    Address1

    ) VALUES (

    123,

    'John Smith',

    '3325 Nowhere Ln'

    )

    -- Hard-coded values,...

  • RE: Subquery with case statement

    If you're aggregating quarters that happen to exist in both tables, I think you want UNION ALL rather than a join. Here's one way - not super pretty, but...

  • RE: Collecting a number of text fields together using group by

    I get requests like that regularly, and use the same technique. Output is Excel or Crystal Reports. The only reason I'd drop it into a table is as...

  • RE: MAX() aggregate function with NULLS

    This one uses EXISTS and UNION. It works for this data set, and I think it works for the general problem set.

    DECLARE @YourTable TABLE (

    clientID...

  • RE: The Old Boys Club

    Off-Topic: " ... using english [sic] correctly ..." "English" should be capitalized when used as a proper noun.

    "I think if everyone took the tact ..." The correct word...

  • RE: Question abount how to make a Ranking

    Grasshopper:

    Try this, let me know if it's what you're after. Note: if all the rows for a given update/snapshot don't have *exactly* the same datetime value, you'll have to...

  • RE: sp Error converting varchar to bigint

    Given that CPIndex is already bigint, it doesn't need to be converted. So borrowing from David's sample:

    CREATE PROCEDURE dbo.viewReport

    @myStaff nvarchar (50),

    @myCoalition nvarchar (50)

    AS

    DECLARE @mainID bigint

    DECLARE @secondaryID bigint

    SELECT @mainid =...

Viewing 7 posts - 1 through 7 (of 7 total)