Forum Replies Created

Viewing 15 posts - 61 through 75 (of 926 total)

  • RE: Multiple row data need to be convert as Coloumn

    You required comma separated values in single column. Following is a code which demonstrate it:

    Declare @Table table

    (

    ID int,

    Code varchar(10),

    score int

    )

    insert into @Table

    select 1,'aa',44 union all

    select 1,'bb',54 union all

    select 1,'cc',74 union...

  • RE: Stop time for loop not recognising time correctly

    Congrats. Thanks for your feedback.

  • RE: Stop time for loop not recognising time correctly

    richardmgreen1 (8/23/2016)


    There's no issue with the file still being in use while trying to copy it as the filename ends with ****tmp.csv while it's still being written. When the "tmp"...

  • RE: Stop time for loop not recognising time correctly

    richardmgreen1 (8/23/2016)


    Hi Jeff

    I've stepped through the code as it is and, in the watch window, the times are the correct format in both cases.

    It appears to be only when the...

  • RE: Stop time for loop not recognising time correctly

    Jeff Moden (8/22/2016)


    I know squat about VB anymore but it seems to me that the following line would be a problem ...

    While Now.ToString("hh:mm:ss tt") < dtStopTime.ToString("hh':'mm':'ss tt")

    ... because the single...

  • RE: Apply Pivot in SQL Server

    Many thanks for clearing my doubt with related examples. These type of things can only be learned either by hands on experience or by asking experienced forum users. Sadly I'am...

  • RE: String or binary would be truncated error.

    Yep that's pretty much what Dixie figured out, and you finished it off nicely. Nice job. I'd still go for avoiding the REPLACE. I don't think they are necessary, in...

  • RE: String or binary would be truncated error.

    ChrisM@Work, +1.

    But if you still interested to use your own code then you just need to convert the NVARCHAR(MAX) when assigning it to @SQL4. Here is the updated query:

    -- Query...

  • RE: Apply Pivot in SQL Server

    Ombir (8/15/2016)


    The Select statement in the APPLY clause doesn't include a FROM clause because it's referencing a column from previous tables (in this case DtlChrg) and making computations on the...

  • RE: Apply Pivot in SQL Server

    Apply Operator is to make the query less complex, rather then to make it more complex.

    For Example:

    If you would have required to have a aggregation on the vChargeCode...

  • RE: Apply Pivot in SQL Server

    I'm learning T-Sql and having hard time to understand how this query works. Every time I see the apply operator in forums, its being applied with different logic.

    Well, If you...

  • RE: Last day of month in a WHERE clause

    I tweaked your query thus to generate the tally on the fly and to change the column names to fit in with my test harness:with N10(n) AS (

    SELECT CAST(n AS...

  • RE: Last day of month in a WHERE clause

    The Dixie Flatline (8/11/2016)


    IF you can afford a nonclustered index on check_date, this will drastically reduce the i/o.

    ;with Eomonths (Eom) as (select top(500) EoMonth(DateAdd(MONTH,(N-1),'1/1/2016')) from tally)

    select Eom as Check_date, Total

    from...

  • RE: Last day of month in a WHERE clause

    Did you test it with datetime?

    Yes i did.

  • RE: Last day of month in a WHERE clause

    Just a minor adjustment to Chris solution, It will not handle if there is date and time are coming in the check_date column.

    Here is Chris updated script:

    SELECT

    t.[Check_date],

    cnt = COUNT(*)

    FROM...

Viewing 15 posts - 61 through 75 (of 926 total)