Forum Replies Created

Viewing 15 posts - 8,176 through 8,190 (of 10,144 total)

  • RE: SQL SERVER 2008 Pivot

    Cool - now plug this new component into your query set in place of the original one which was unordered and giving you dupes.

  • RE: Split out a table by date?

    -- Make some sample data

    DROP TABLE #TableWithStartAndEndDate

    CREATE TABLE #TableWithStartAndEndDate (TiD INT, StartDate DATETIME, EndDate DATETIME)

    INSERT INTO #TableWithStartAndEndDate (TiD, StartDate, EndDate)

    SELECT 1, '2010-01-18 01:00:00.000', '2010-01-25 23:00:00.000' UNION ALL

    SELECT 2, '2010-01-18 02:00:00.000',...

  • RE: SQL SERVER 2008 Pivot

    -- Sample data setup for #sipDimensionPos

    --===== Create table

    DROP TABLE #sipDimensionPos

    CREATE TABLE #sipDimensionPos(

    [id_pos] [bigint] NULL,

    [id_cliente] [bigint] NOT NULL,

    [razonSocial_cliente] [varchar](100) NULL,

    [id_CliPadre] [int] NULL,

    [nombre_CliPadre] [varchar](100) NULL,

    [id_canal] [smallint] NULL,

    [id_sucursal] [smallint] NULL,

    [establecimiento] [varchar](100) NULL,

    [nombre_Localidad] [varchar](100)...

  • RE: SQL SERVER 2008 Pivot

    -- @PivotCliPadres populated

    -- with distinct values, and in order

    DECLARE @PivotCliPadres VARCHAR(1000)

    SELECT @PivotCliPadres = COALESCE(

    @PivotCliPadres + ',[' + cast(id_CliPadre as varchar) + ']',

    '[' + cast(id_CliPadre as varchar)+ ']')

    FROM (

    SELECT id_CliPadre

    FROM...

  • RE: Not getting desired results

    There's another way of writing this type of query which might be more intuitive to you, and help you along with your new query. This replaces the query as in...

  • RE: Are the posted questions getting worse?

    TSQL101 at Mumbai Tech.

    Graduate as a Senior Software Engineer.

  • RE: Not getting desired results

    This might run faster:

    SELECT c.crs_id AS id,

    c.crs_name,

    c.crs_author,

    c.sch_start,

    c.sch_end

    FROM SNP_crs c

    --INNER JOIN SNP_crsunits u ON u.crs_id = c.crs_id

    --INNER JOIN SNP_media m ON m.crsunit_id = u.crsunit_id

    LEFT JOIN (SELECT ud.crs_id

    FROM...

  • RE: Not getting desired results

    jordon.shaw (1/25/2010)


    That's it! You're a genus! Thank you so much for your help!!!

    Heh not quite mate, just a jobbing programmer, but thanks.

    Do you really need the aggregated columns...

  • RE: Not getting desired results

    SELECT c.crs_id AS id,

    c.crs_name,

    c.crs_author,

    c.sch_start,...

  • RE: Not getting desired results

    Which output columns vary within the "group by"? Have a gander at them, and decide which of your options would best suit you: MIN / MAX / AVG etc

  • RE: Not getting desired results

    No worries mate.

    Have a look at this, I reckon it's getting close:

    SELECT c.crs_id AS id,

    c.crs_name,

    ...

  • RE: Not getting desired results

    jordon.shaw (1/25/2010)


    Chris Morris-439714 (1/25/2010)


    Nope, wasn't meant to. There are a few questions at the bottom of the code list, any chance of an answer?

    I had posted my table structure. ...

  • RE: Query multiple descriptions from single field of codes

    Jeff Moden (1/24/2010)


    lobbymuncher (1/24/2010)


    Here's a completely different way which returns the codes in the same row.

    Oh... be careful... you have to consider how hard the I/O system needs to work...

  • RE: Not getting desired results

    jordon.shaw (1/24/2010)


    That still isn't working.

    Nope, wasn't meant to. There are a few questions at the bottom of the code list, any chance of an answer?

  • RE: charindex or like condition

    This is worse than the original query and the suggestions which have been made have not been implemented.

    Are you able to create a view or stored procedure on the...

Viewing 15 posts - 8,176 through 8,190 (of 10,144 total)