Forum Replies Created

Viewing 15 posts - 1,621 through 1,635 (of 2,007 total)

  • RE: SQL Query for MI Report

    drew.allen (6/14/2011)


    A couple of things that I wanted to point out.

    * You use this formula repeatedly in your query DATEADD(MINUTE,-@interval,DATEADD(MINUTE,N*@interval,@starttime)) I moved it into the CTE so that...

  • RE: SQL Query for MI Report

    Dan.Humphries (6/14/2011)


    I might suggest reposting this thread with the scripts as an attachment. The Sample data scipt you posed is too large and causes the browser to lock up....

  • RE: Increment a date T-SQL Statement

    m_cg (6/7/2011)


    Jeff,

    Still not sure of the format, but gave it 2 ways. Does this work for you?

    What Jeff's talking about is using a Tally table.

    e.g.

    DECLARE @date DATETIME, @number INT

    SET @date...

  • RE: Two similar queries returning completely different results!!!

    Ordering is not guaranteed when you do not specify order by clause. So if you have no order by clause, then the query optimizer is free to return rows in...

  • RE: Increment a date T-SQL Statement

    drew.allen (6/3/2011)


    skcadavre (6/3/2011)


    When you post sweeping comments, you should probably include a test script that proves what you're claiming. Note, I'm not saying you're wrong. As I said before, I...

  • RE: Increment a date T-SQL Statement

    drew.allen (6/2/2011)


    Jnrstevej (6/2/2011)


    Hi skcadavre,

    Thanks for your reply, its not a homework question i'm in the process of designing a SSRS report and i need this section in the store procedure...

  • RE: Increment a date T-SQL Statement

    Like so: -

    DECLARE @date DATETIME, @number INT

    SET @date = '2011-06-06 00:00:00'

    SET @number = 12

    ;WITH CTE AS (

    SELECT 0 AS months

    UNION ALL

    SELECT months + 1

    FROM CTE

    WHERE months < @number-1)

    SELECT DATEADD(MONTH,months,@date),

    CONVERT(VARCHAR(10),DATEADD(MONTH,months,@date),...

  • RE: Increment a date T-SQL Statement

    Is this a homework question? I ask because I answered something almost identical to this a couple of days ago (here). . .

    One way would be to do it like...

  • RE: Data format in T-SQL 2005

    GilaMonster (6/1/2011)


    NText for a date? I wasn't aware dates could reach 2 billion unicode characters in length...

    I guess that should've been my first comment - before complaining about presentation layer...

  • RE: Data format in T-SQL 2005

    This is a presentation layer task, not a SQL task.

    That being said, one way to do it in SQL would be: -

    --Create test data

    DECLARE @testdata AS TABLE (dates NTEXT)

    INSERT INTO...

  • RE: Calculate last 6 month month end date

    One simple way: -

    DECLARE @date DATETIME, @number INT

    SET @date = '2011-06-01 00:00:00'

    SET @number = 6

    ;WITH CTE AS (

    SELECT @number-1 AS months

    UNION ALL

    SELECT months - 1

    FROM CTE

    WHERE months > 0)

    SELECT...

  • RE: Cursors for T-SQL Beginners

    Whenever possible, I use set-based solutions. But it has occurred in the past where I simply couldn't think one.

    For example, this is my answer to a question on this site...

  • RE: How to split and update to table

    Like this?

    --First, lets build some ready consumable test data

    DECLARE @TABLE AS TABLE(ID INT IDENTITY, CityName VARCHAR(20))

    INSERT INTO @TABLE

    SELECT 'Phnom Penh </Title>'

    UNION ALL SELECT 'Siem Reap</Title>'

    --Select from table

    SELECT * FROM @TABLE

    --Now...

Viewing 15 posts - 1,621 through 1,635 (of 2,007 total)