Forum Replies Created

Viewing 15 posts - 121 through 135 (of 337 total)

  • RE: I need a pivot of this data

    Replace EXEC(@sql) with PRINT(@sql) and check the output of the print statement.Try running the printed sql in the query window.

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: How to: Bulk import xml to table

    You need to post here the Table and XML structure..

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: Running total in sql and additional issue

    Something like this

    SELECT SUM(YourSum) FROM

    (

    SELECT SUM(CASE WHEN SOA_TYPE = 'Agent' THEN USD_AMOUNT ELSE 0 END) +

    SUM(CASE WHEN SOA_TYPE = 'Freight' THEN USD_AMOUNT ELSE 0 END) +

    SUM(CASE WHEN SOA_TYPE...

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: How to pick data from 1am to 1am, the previous day

    Using TimeFromParts function.

    DECLARE @startDate datetime , @endDate datetime ,@getdate date

    SET @getdate = getdate()-1

    SET @startDate = convert(varchar(30),@getdate) + ' ' + convert(varchar(30),Timefromparts(01,0,0,0,0))

    SET @endDate =@startDate+1

    SELECT *

    FROM TABLE

    WHERE [datetime] BETWEEN @startDate AND @endDate;

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: I need a pivot of this data

    oradbguru (6/19/2014)


    Sorry, I should have stated that they will not always be the same. Thank you.

    In that case you can use the second query I had posted.

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: Unable to get the required result using update statement

    CREATE TABLE #patient_readmission

    (

    id INT IDENTITY,

    ...

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: SQL Server 2008 R2 Memory

    Value of stolen pages looks quite high to me.Stolen=4125133.Lots of hash and sort operations ?

    Value of PLE also seems quite low,only 632 for a 64 GB memory.

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: I need a pivot of this data

    If the lictype's are known in advance you can simply use this

    SELECT pmdescription,

    smdescription,

    mstr_list_item_desc,

    ...

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: I need a pivot of this data

    Will the lictype always be of these 3 types ?

    HealthWise

    PatientPortal

    RealTime

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: Unable to get the required result using update statement

    Why should the value of Index_AMI be 1 for encounter id=16260 though the previous discharge date is less than 30 days of the admit date ?

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: Finding Breaks In Key Values

    Here is a non SQL 2012 method.This would require a row identifier column which I believe every table should have.But personally I have seen LEAD/LAG functions performing way better than...

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: 4 query=1 query

    I dont think there is need for query 2 as you are already grouping and aggregating on the same columns in query 1.

    Can you verify whether the resultset from query...

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: Pre 2012 Stored Procedure: Need some DEV advice (COMPUTE BY TO WITH ROLL UP)

    The error is not because of the change.The error is thrown by the SP instead.Try searching for text "No records were found macthcing your criteria" in the SP.

    matching in misspelled...

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: Is there a way to do this without dynamic sql?

    Another use of LEAD function

    SELECT QueueId,TaskId,TaskName,Rundatetime FROM(

    SELECT T.QueueId,T.TaskId,T.TaskName,T.RunDateTime, LEAD(taskid,MaximumQueueLength)OVER(PARTITION BY T.QueueId ORDER BY taskid DESC)lid FROM Tasks T

    INNER JOIN Queue Q ON T.QueueId=Q.QueueId

    )T1 WHERE lid IS NULL ORDER BY TaskName

    EDIT:...

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • RE: Pre 2012 Stored Procedure: Need some DEV advice (COMPUTE BY TO WITH ROLL UP)

    Simply comment the compute part and replace with a SELECT statement

    -- COMPUTE SUM([Total(MB)]), SUM([Unused(MB)]), SUM([Used(MB)]), SUM([Index(MB)]), SUM([Data(MB)])

    SELECT SUM([Total(MB)]), SUM([Unused(MB)]), SUM([Used(MB)]), SUM([Index(MB)]), SUM([Data(MB)]) FROM dbo.##FO

    Would work for all SQL...

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

Viewing 15 posts - 121 through 135 (of 337 total)