Forum Replies Created

Viewing 15 posts - 6,736 through 6,750 (of 10,143 total)

  • RE: get date of first monday of the given year?

    Fast and accurate:

    SELECT [FirstMonday] = DATEADD(dd,CASE x.wd WHEN 'mo' THEN 0 WHEN 'su' THEN 1 WHEN 'sa' THEN 2 WHEN 'fr' THEN 3 WHEN 'th' THEN 4 WHEN 'we' THEN...

  • RE: Inserting summarized data

    This incorporates many of the changes suggested to date and replaces the cursor with a local temporary table.

    ALTER PROCEDURE [dbo].[cust_CreateJournalEntry]

    @PO_NUMBER VARCHAR(10)

    ...

  • RE: help with an sql problem

    Heh! Funny - I thought your solution had a triangular join but it isn't. That >= ALL () appears to be very efficient with this small data set. It's twice...

  • RE: help with an sql problem

    Sure.

    SELECT

    d.[rec_index],

    d.file_desc,

    d.is_modified

    FROM (

    SELECT

    [rec_index],

    file_desc,

    is_modified,

    rn = ROW_NUMBER() OVER(PARTITION BY file_desc ORDER BY rec_index...

  • RE: help with an sql problem

    dardar4 (8/17/2011)


    thnx for the help but that didn't work

    insert into MyTable (file_desc, is_modified) values ('a.txt',0)

    insert into MyTable (file_desc, is_modified) values ('a.txt',1)

    insert into MyTable (file_desc, is_modified) values ('b.txt',0)

    insert into...

  • RE: help with an sql problem

    Thanks for the sample data.

    The simplest solution to this is the following:

    SELECT

    file_desc,

    rec_index = MAX(rec_index)

    FROM MyTable

    WHERE is_modified = 0

    GROUP BY file_desc

    There's no need to incur the cost and...

  • RE: help with an sql problem

    It's a simple aggregate.

    Have you read the introductory article [/url]yet?

    Writing a few INSERT statements will take you seconds.

    It will only take us seconds to write your query but without...

  • RE: help with an sql problem

    Like this:

    CREATE TABLE #Sample (some_index INT, [file_name] nvarchar(50), is_modified bit)

    INSERT INTO #Sample (some_index, [file_name], is_modified)

    SELECT 1, 'anything.txt', 0

    but with a few more rows.

    Don't name a column [index], or...

  • RE: help with an sql problem

    dardar4 (8/17/2011)


    hi all

    i have a table with those columns: index[int], file_name[nvarchar(50)], is_modified [bit]

    i need to write an sql statement that will do the following:

    go over all the records in the...

  • RE: Returning row count as output in CTE

    Lowell (8/16/2011)


    ChrisM@Work (8/16/2011)


    Was it the key seek method, explained elegantly by Paul White here[/url]?

    that post from Paul exactly encapsulates that portion of his presentation Chris, yes.

    ยป Dmitri Korotkevitch's web site,...

  • RE: nothing returning for date

    Vlad-207446 (8/16/2011)


    SSC -- please disregard my post with all that crazy function of mine ๐Ÿ™‚ it was designed for something else and I just tried to adapt it...

  • RE: Help Doing A Comparison Calculation With Current Date

    GSquared (8/16/2011)


    Chris, I think he's probably using some variation of a Calendar Table. Those are the best way to calculate things like working days and such, and it looks...

  • RE: Help Doing A Comparison Calculation With Current Date

    It has to be easier than this. You don't need a table of weekends, you can calculate them:

    DECLARE

    @HolStartDate DATETIME = '17/08/2011',

    @HolEndDate DATETIME = '27/08/2011'

    SELECT DATEADD(dd,rn,@HolStartDate)

    FROM (SELECT top 100 rn...

  • RE: Returning row count as output in CTE

    Lowell (8/15/2011)


    i just sat in on a SQLSaturday #79 in Davie(Fort Lauderdale) presentation on how to improve performance in exactly this situation;

    the Presenter was Dimitri, and he had a great...

  • RE: nothing returning for date

    spin (8/16/2011)


    wow. a little more complicated than i'd expected. trying to get my head around this now. i'll let you know if it works out. thanks.

    It doesn't need to be...

Viewing 15 posts - 6,736 through 6,750 (of 10,143 total)