Forum Replies Created

Viewing 15 posts - 496 through 510 (of 627 total)

  • RE: Removing 00-00-00 from varchar Column in SQL table

    sheaS (7/29/2015)


    Ok, awesome guys, I'll convert it to a date first then run these query's. Thanks a million. Will post results.

    If you're going to convert it then you don't actually...

  • RE: Removing 00-00-00 from varchar Column in SQL table

    Well we had a REPLACE and a LEFT solution why not add a CONVERT. 😉

    DECLARE @mytable TABLE (myDate VARCHAR(20))

    INSERT INTO @mytable

    VALUES ('2015-07-28 00:00:00'),('2015-07-29 00:00:00'),('2015-07-30 00:00:00')

    SELECT * FROM @mytable

    UPDATE @mytable

    SET myDate...

  • RE: how to reclaim space

    rightontarget (7/21/2015)


    Yes, the way I see it, if database size is nearly 5 times bigger than data, it is an issue. What is or how to properly maintain it? This...

  • RE: how to reclaim space

    The first thing you need to realize is that the size of your data file is not the same thing as the amount of data you have. When the...

  • RE: table size difference in two DB

    It's not all that strange when you realize how SQL stores data. Several factors can affect size such as fill factor for example. In you case the biggest...

  • RE: Date question

    If you run these two select statements it will give you a clue as to where the issue is. (as well how to fix it) 😉

    SELECT CAST(2015-07-20 AS DATETIME)

    SELECT CAST('2015-07-20'...

  • RE: Queue Table Strategies

    TheSQLGuru (7/13/2015)


    If all else fails ...

    Be VERY VERY careful with what that statement REALLY means. You are doing data processing, and if all else fails you could process...

  • RE: Queue Table Strategies

    Thanks for the input guys. I checked out Kejser's blog and he has some really interesting things to say on the subject. This may be the simplest to...

  • RE: "ID" or "Id"

    Jeff Moden (7/8/2015)


    yb751 (7/8/2015)


    Where I work "ID" was used everywhere if it was the primary key. Then foreign keys would become AccountID for example. Programmers claimed it was...

  • RE: "ID" or "Id"

    Where I work "ID" was used everywhere if it was the primary key. Then foreign keys would become AccountID for example. Programmers claimed it was easier for them...

  • RE: expanding the keyword AS

    Ahhh...now I understand. Yes, you'll need to use Dynamic SQL for that.

  • RE: expanding the keyword AS

    Maybe I misunderstand but if you simply want 'Month1: 07/07/2015' as a column name did you try...

    SELECT 1 AS [Month1: 07/07/2015]

    Just a simple example but as you can see the...

  • RE: Help with SQL - Calculate time difference for consecutive rows

    That being said he mentioned it worked for a single S_ID but I went by S_USER.

    In that case...

    TEST for single ID

    SELECT

    S_ID,

    LAG(S_ACTV_CODE, 1) OVER (ORDER BY S_DATETIME ASC) AS S_ACTV_CODE_PREV,

    S_ACTV_CODE,

    S_USER,

    S_DATETIME AS...

  • RE: Help with SQL - Calculate time difference for consecutive rows

    Hmmm...not sure why but I just double checked and it looks fine here. I also checked the other 'users' separately with expected results.

  • RE: Help with SQL - Calculate time difference for consecutive rows

    Since you (the OP) stated that your query worked with a single user I just used your own code with a specific user for testing.

    SELECT

    S_ID,

    LAG(S_ACTV_CODE, 1) OVER (ORDER BY S_DATETIME...

Viewing 15 posts - 496 through 510 (of 627 total)