Forum Replies Created

Viewing 15 posts - 796 through 810 (of 1,923 total)

  • RE: Stored Proc with dynamic table column

    thbaig1 (5/4/2011)


    ColdCoffee (5/4/2011)


    As Ninja put it, the solution might not be an efficient one. Can be done in 3 parts.

    1. UNPIVOT your columns - this will be dynamic as u...

  • RE: how to write this query

    Using GSquared's sample data, is this what you are trying to acheive?

    SELECT DATEADD( DD , DATEDIFF(DD,0,DT) ,0) Days ,

    MAX(Int1) Int1_Mx,

    ...

  • RE: Assistance with SQL

    DSR0308 (5/4/2011)


    that is correct. I am just looking to get two days sales...

    Yestrerday Sales (becasue im reporting of a datawarehouse) and same time last yeear.

    Then the query i gave you...

  • RE: Assistance with SQL

    Ninja's_RGR'us (5/4/2011)


    I know, I'm saying to use between so that you don't force a scan because of non sargable condition.

    DimDate.FeeWeekEndDate > DATEADD(D, 0, DATEDIFF(D, 0, GETDATE())) AND DimDate.FeeWeekEndDate < DATEADD(D,...

  • RE: Assistance with SQL

    Ninja's_RGR'us (5/4/2011)


    WHERE (

    DATEADD( DD , DATEDIFF(DD,0,DimDate.FeeWeekEndDate ),0) = @ThisDayLastYR

    OR

    ...

  • RE: Assistance with SQL

    SQLRNNR (5/4/2011)


    You might want to change the variable in the first case statement to be @Today

    Yep, Jason is right. Post edited to correct the error.

  • RE: Stored Proc with dynamic table column

    As Ninja put it, the solution might not be an efficient one. Can be done in 3 parts.

    1. UNPIVOT your columns - this will be dynamic as u don't know...

  • RE: Assistance with SQL

    Try this:

    DECLARE @Today DATETIME = DATEADD( DD , DATEDIFF(DD,0,GETDATE()),0),

    @ThisDayLastYR DATETIME

    SELECT @ThisDayLastYR = DATEADD( YEAR , -1,@Today)

    select @Today , @ThisDayLastYR

    SELECT

    DimGeography.GeographyKey,

    DimGeography.Country,

    DimGeography.GeneralRegion,

    DimGeography.LocalRegion,

    DimGeography.City,

    tblStore.Longitude,

    tblStore.Latitude,

    DimDate.Year,

    DimDate.Month,

    DimDate.FeeWeek,

    DimDate.FeeWeekEndDate,...

  • RE: How to Denormalize Data / How to Flatten Normalized Data

    For starters, you can use

    1. GROUP BY with MAX(CASE END) to get a row turned into columns

    2. CROSS APPLY twice (or once) to get rows added as columns to...

  • RE: How to Denormalize Data / How to Flatten Normalized Data

    Hey YSL, with 649 points to your name, you sure must be knowing how to post your question so that you get maximum response. Please post sample data as INSERT...

  • RE: Assistance with SQL

    You want to get Sales Information for last year or this year or both?

  • RE: add $ sign and number to table

    Convert the amount column to VARCHAR(x) and concatenate the dollar symbol.. am not aware of any direct methods for that..

  • RE: Replace in String

    piotrka (5/2/2011)


    Try this

    CREATE TABLE [dbo].[Test_1](

    [String1] [nchar](100) NULL,

    [String2] [nchar](100) NULL

    ) ON [PRIMARY]

    insert into dbo.Test_1

    select 'P:\SQL Database Backups\Transaction Logs\',

    '\AdventureWorks_TransLog_201105021530.trn'

    select LEFT(string1, LEN(string1) - 1) + LTRIM(string2)

    from Test_1

    Hi piotrka, try your...

  • RE: Replace in String

    Lowell query:

    SELECT CASE WHEN RIGHT(ThePath,1) <> '\' THEN ThePath ELSE REVERSE(SUBSTRING(REVERSE(ThePath),2,100)) END + CASE ...

  • RE: Replace in String

    AndrewSQLDBA (5/2/2011)


    But I am not at all sure why you are including all the UNION All statements. And using a CTE method.

    Those UNION ALL are not part of the replace...

Viewing 15 posts - 796 through 810 (of 1,923 total)