Forum Replies Created

Viewing 15 posts - 2,701 through 2,715 (of 4,087 total)

  • RE: Show Status by Month End

    pietlinden (5/8/2016)


    This is Lynn Pettis' calculation[/url] for first day of the next month...

    select dateadd(mm, datediff(mm, 0, @ThisDate) + 1, 0) -- Beginning of next month

    last day of the month is...

  • RE: Find Duplicate Records in Table and Update one of them.

    Con Alexis (5/8/2016)


    Depending on number of rows, and indexes etc... but I would usually do a "GROUP BY" to identify dupes together with MIN to identify original record, then joining...

  • RE: Date DImension Query

    o103452 (5/6/2016)


    Sergiy (5/5/2016)


    Create a calendar table having a record for each day you company has been or will be filing tax reports.

    Not sure if it's good or bad, but there...

  • RE: Date DImension Query

    o103452 (5/5/2016)


    Hi guys,

    I'm working on modifying the fiscal date script from here.

    I'm trying to figure out how to calculate the following.

    FiscalWkofQrt

    -- Week # of each querter where it resets every...

  • RE: Need some help transposing a query

    Given the name MASTER_CODING_RESULTS_ID, it's highly likely that this is the primary key, in which case there is no reason to reference the table more than once.

    Drew

  • RE: Need to insert Reocrds in uniqueidentifier column

    If you want a unique identifier with all zeroes, you can always do the following.

    SELECT CAST(0x0 AS UNIQUEIDENTIFIER)

    Drew

  • RE: How to show CAPS lock status in Management Studio status bar?

    SQL Prompt will automatically adjust the case, so I don't care whether caps lock is on. Also, it becomes quickly obvious as you're typing that the wrong case is...

  • RE: Help Using Cursor

    This is my best guess at doing this WITHOUT A CURSOR.

    I combined your two derived tables into one by using the LAG function and removed unnecessary conditions in your CASE...

  • RE: How to generate new Int ID for multiple columns

    Alan.B (5/4/2016)


    ROW_NUMBER does not take ties into consideration, RANK and DENSE_RANK do.

    I would phrase that differently. They all take ties into consideration: RANK and DENSE_RANK treat ties as...

  • RE: Join the same source tablle twice

    Ed Wagner (5/3/2016)


    I guess I must not understand the question either. From the way I read it, I would do something like this:

    SELECT TOP 2 DateColumn

    FROM dbo.TableName

    ...

  • RE: Get the time difference of 80% of total record

    salliven (5/4/2016)


    Maybe this query?

    ;with cte as (

    select TOP (select ((MD.TotalCount*80)/100) as TotalCount from [dbo].[Message_Identifier] MD where MD.MessageID = 1141)

    DMQD.SubmitDate

    from [dbo]. message_queue_details

    DMM DMM.MessageID = 1141

    order by SubmitDate

    )

    select

    DATEDIFF(SECOND,MIN(SubmitDate), MAX(SubmitDate)) as TimeDiff

    from cte

    I...

  • RE: efficient Querying - NOT EXISTS

    ScottPletcher (5/3/2016)


    You need to create an index on ID in T2, T3, T4, T5 and T6.

    You should check the tables in the order of most likely to EXIST first, so...

  • RE: Historical Date

    PSB (5/3/2016)


    Server is UTC time zone .

    I just need to delete today's records and insert new ones and keep yesterday and older records. Rest (time zone) is not mandatory.

    If the...

  • RE: Find column values based on min and max of other columns

    John Mitchell-245523 (4/29/2016)


    Or this - probably more efficient since it only involves a single scan:

    SELECT DISTINCT

    ID

    ,IDDATE

    ,FIRST_VALUE(FROMID) OVER (PARTITION BY ID, IDDATE ORDER BY JID) AS FROMID

    ,FIRST_VALUE(TOID) OVER (PARTITION BY ID,...

Viewing 15 posts - 2,701 through 2,715 (of 4,087 total)