Forum Replies Created

Viewing 15 posts - 1 through 15 (of 32 total)

  • RE: LTRIM,RTRIM

    daveriya (10/21/2011)


    hi

    i have this code in where clause RTRIM(LTRIM(ODER_ID))= ' ',WHAT THis do

    It's just removing extra blank spaces, but this is un-necessary as SQL views empty strings as empty strings...

  • RE: conversion failed when converting the nvarchar value to data type int.

    Ok it runs for me but I made my own 'datasource' table so the data may be differnt.

    Please post DDL and sample data from the table we are running these...

  • RE: conversion failed when converting the nvarchar value to data type int.

    This statement:

    when Convert(nvarchar(255),Left(A.Comments,Charindex('|', A.Comments,1)-1)) < 0

    is what is giving your error.

    You are doing a less than comparison between nvarchar data and an integer here.

    I assume you mean to return...

  • RE: Making two tables into one

    Do you have any way to relate the rows in the table to the ones in the file?

  • RE: Is there a "tables collection" in T-SQL?

    SELECT CASE WHEN ROW_NUMBER() OVER (ORDER BY object_id) > 1 THEN 'UNION ALL ' ELSE '' END +

    'SELECT * FROM '...

  • RE: Partitioning

    You can return the partition ID this way:

    $partition.partitionFunctionName(partitionColumn)

  • RE: Daily amount

    I think I see what's happening now, its taking the amount as opposed to the calculated amount so for the first two rows coincidentally it was correct but once you...

  • RE: Daily amount

    WITH CTEDATE AS (

    SELECT DATEADD(DAY,num-2,(SELECT MIN(transDATE) FROM transTest)) [date]

    FROM dbo.Nums

    WHERE num <= DATEDIFF(DAY,(SELECT MIN(transDATE) FROM transTest),(SELECT MAX(transDATE) FROM transTest)) + 2

    ),CTEAMT AS (

    SELECTrow_number() over(order by b.[date]) [rownum]

    ,B.[date]

    ,isnull(SUM(amount),0) [amt]

    FROM transTest A

    RIGHT...

  • RE: Daily amount

    Lynn Pettis (10/6/2011)


    Based on the sample data what is your expected results and what are the criteria?

    Hi Lynn, run this to see expected result set based on sample data.

    SELECT '2011-10-02...

  • RE: cumillative total

    You can do cumulative totals using a correlated subquery.

    SELECT id,dt,amt,(SELECT SUM(amt) FROM #t b WHERE a.id = b.id AND a.dt >= b.dt)

    FROM #t a

  • RE: Windowed function in update

    Hi can you post some DDL with some test data, I think I know a way to do this but I'd like to verify it with your data if possible.

  • RE: Logic Help

    Very nice!

    Yeh Im not sure why I didnt have the partition by FK_ID, I think when I was initially testing it I put a WHERE clause in the first CTE...

  • RE: Logic Help

    EDIT:

    Scratch that, doesn't quite work after verifying the data. But I will leave it up, maybe someone can use it as a basis to get it 100% correct. I will...

  • RE: Query Performance

    Grant Fritchey (10/5/2011)


    chandan_jha18 (10/5/2011)


    Thanks. I was trying to remove the cast functions in the 'on' filter which Grant mentioned sometime ago.

    But as you(Paul and Grant) mentioned about posted date...

  • RE: Which SQL Server installations I can remove?

    You're safe to remove Microsoft SQL Server 2008 as that looks like its the Express instance you installed.

    Everything which says 2008R2 is part of the second instance you installed (the...

Viewing 15 posts - 1 through 15 (of 32 total)