Forum Replies Created

Viewing 15 posts - 46 through 60 (of 65 total)

  • RE: GROUP BY question

    SELECT DISTINCT

    ID =lot.value

    , SiteID = DENSE_RANK()OVER(ORDER BY Country DESC)

    ,Country

    FROM SiteMatches

    CROSS APPLY (

    VALUES('RetainedRID', RetainedRID)

    , ('DroppedRID', DroppedRidd )) Lot(name,value)

  • RE: select the output of stored procedure with count of returned rows

    ok so you are trying to execute stored proc inside join. Also the IF statement should be outside.

    If you can get the date from this stored proc and then...

  • RE: Help with Idea on Round Robin TSQL solution

    WOW this is great!!

    HAPPY SATURDAY! Thank you for your time I appreciate it.

    Thanks again,

    Brad

  • RE: CASE in WHERE clause

    Forgot to include cache

    Also checking statistics (SET STATISTICS IO ON) and clearing cache [/b]before executing each stored proc.

    --Do not run in PROD!!!

    DBCC FREEPROCCACHE

    DBBC DROPCLEANBUFFERS

  • RE: CASE in WHERE clause

    In this case I would have both the Dynamic SQL stored proc and non dynamic stored proc.

    Compare both the execution plans. Also checking statistics (SET STATISTICS IO ON) and clearing...

  • RE: Stuck on new fault with my update

    Hey Alan,

    I am basically guessing here what data looks like. If you could provide more detail you would be able to get additional expert advice.

    If your PK...

  • RE: Stuck on new fault with my update

    I would create temp table or CTE and then use that to do insert update. The "ID" field is your PK of the table.

    IF OBJECT_ID('tempdb..#Source','u') IS NOT NULL

    DROP TABLE...

  • RE: Help in creating T-SQL where clause

    I attended a training by Itzik Ben Gan and we found that this technique worked the best for our data set.

    -- Stored Procedure GetOrders,

    -- Using Dynamic SQL

    ALTER PROC dbo.GetOrders

    ...

  • RE: Output multiple SQL query result into excel using SSIS

    Some ideas to help.

    For Each Loop Container and through folder of sql scripts picking up the sql file name and using this as a variable. Use a Command Line task...

  • RE: Trigger not firing

    Can you try and use the inserted table?

    SELECT email, customerId

    FROM Inserted

    WHERE inserted.VatRegistrationID = '' and inserted..email <> ''

  • RE: Trigger not firing

    I am not sure what is going on with your trigger.

    For debugging dynamic sql, I usually will add a PRINT @Sql statement above the EXEC @SQL statement and comment out...

  • RE: Grouping by ten days period

    A possible solution. I am assuming every month is 31 days but an idea to help you get started.

    WITH TenDates

    AS

    (

    SELECT

    s_date

    , DayAdd =

    CASE WHEN DAY(s_date) <=...

  • RE: Query assistance request

    This above option will not work as DocType is not in Encounters. Using not exists is another option I was shooting for.

    SELECT e.EncounterNo, e.EncntrStartDate, d.DocType, m.MedRecNo, ee.EnrolleeName

    FROM Encounters...

  • RE: Query assistance request

    How about this option?

    SELECT e.EncounterNo, e.EncntrStartDate, d.DocType, m.MedRecNo, ee.EnrolleeName

    FROM Encounters e (NOLOCK)

    JOIN DocsOwners do (NOLOCK) ON e.EncntrOwnerId = do.OwnerId

    JOIN Documents d (NOLOCK) ON do.DocId = d.DocId

    JOIN MedicalRecords AS m (NOLOCK)...

  • RE: Running Total and then every 20

    Thank you very much Right There. Your solution does work for the data set I provided, however I added two additional records that cause this to not work. I ended...

Viewing 15 posts - 46 through 60 (of 65 total)