Forum Replies Created

Viewing 15 posts - 706 through 720 (of 2,007 total)

  • RE: Get a range of numbers

    michael vessey (5/2/2012)


    wouldn't this be easier to do with a recursive CTE?

    declare @start bigint=99;

    declare @end bigint=147;

    with x (num) as

    (

    select 1 as num

    UNION ALL

    SELECT num+1 from x

    where num <@end

    )

    select *...

  • RE: use pivot instead of alter table

    elham_azizi_62 (5/2/2012)


    I could download this zip file.please try again.thanks

    I didn't say I can't, I said I won't. I don't have control over your machine, so I don't know what it...

  • RE: use pivot instead of alter table

    Last try from me, I won't download a zip file. Please post the readily consumable sample data and ddl scripts in a post.

    So until you do as requested, I'm out.

  • RE: use pivot instead of alter table

    I'm not downloading a zip file, and I'm sure many others won't either.

    Instead, follow the example laid out in this article (which I've already linked you to once)[/url] and post...

  • RE: Why cant I reference a column in a SQL Cursor?

    I'm going to take a bit of a guess, because so far you're not very clear.

    This is ugly, needs to be tidied up and requires some performance tuning. It's...

  • RE: t-sql query

    Phil Parkin (5/1/2012)


    Eugene Elutin (5/1/2012)


    ...

    Using != instead of <> is not recommended, as != is non-ISO standard (though it still works).

    ...

    I prefer to use "!=" over "<>". Is any reference...

  • RE: use pivot instead of alter table

    Hello and welcome to SSC!

    I'd like to be able to help you, but it seems you've forgot to post readily consumable sample data, ddl scripts or expected results based on...

  • RE: Why cant I reference a column in a SQL Cursor?

    No problem, make sure you post with any questions you have.

  • RE: t-sql query

    justmohit (5/1/2012)


    I think this code will work for u.

    Select r1.*,r4.Name+ '/' + r3.Name + '/' + r2.Name + '/' + r1.Name

    From Roots r1

    Inner Join Roots r2 on r1.ParentId=r2.ItemId

    Inner Join Roots...

  • RE: Why cant I reference a column in a SQL Cursor?

    blandry (4/30/2012)


    None the less, you are correct that I tend to approach data in more a 'waterfall' type approach than a set based one - and yes, I know I...

  • RE: Why cant I reference a column in a SQL Cursor?

    The CTE that I posted for you generates the months between a start date and now, was that not what you were after?

    It is massively faster than a cursor...

  • RE: Why cant I reference a column in a SQL Cursor?

    Please don't use a cursor for this. . .

    WITH CTE(n) AS(SELECT 1 UNION ALL SELECT 1),

    CTE2(n) AS (SELECT 1 FROM CTE x, CTE y),

    CTE3(n) AS (SELECT 1 FROM CTE2 x,...

  • RE: Calculating time difference

    pwalter83 (4/26/2012)


    Thanks for your reply, however I am unable to understand your code. I have reached upto the point where I am able to calculate the minutes difference. However, the...

  • RE: Generating Test Data: Part 2 - Generating Sequential and Random Dates

    Jeff Moden (4/26/2012)


    Cadavre (4/26/2012)


    Nicely explained Jeff.

    I may have to "borrow" your method of generating random DATETIME data, my method is more difficult to understand when people glance at it. 😀

    Borrow...

  • RE: Calculating time difference

    ChrisM@Work (4/26/2012)


    LOL quite right too!

    I'd use iTVF's for this, A to B and B to A, and SUM across seconds to a bigint - what do you reckon, Cadavre?

    Probably the...

Viewing 15 posts - 706 through 720 (of 2,007 total)