Forum Replies Created

Viewing 15 posts - 7,426 through 7,440 (of 10,144 total)

  • RE: SubSelect Statement not returning accurate results

    No worries.

    Consider making your WHERE clauses SARGable:

    DECLARE @Startmonth DATE, @Endmonth DATE, @Startday DATE, @Endday DATE

    SET @Startmonth = DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE()),0)

    SET @Endmonth = DATEADD(MONTH,1,@Startmonth)

    SET @Startday = DATEADD(day,DATEDIFF(day,0,GETDATE()),0)

    SET @Endday = DATEADD(day,1,@Startday)

    SELECT @Startmonth, @Endmonth, @Startday,...

  • RE: SubSelect Statement not returning accurate results

    You forgot to correlate your correlated subquery:

    SELECT OwnerStaff_Branch,

    COUNT(WorkOrderID) AS MonthTotal,

    (SELECT COUNT(WorkOrderID) AS Expr1

    FROM WorkOrderReportView

    WHERE (dbo.DateOnly(CreatedOn) = dbo.DateOnly(GETDATE())

    AND OwnerStaff_Branch = w.OwnerStaff_Branch)

    ) AS DailyTotal

    FROM WorkOrderReportView w

    WHERE (MONTH(CreatedOn) = MONTH(GETDATE())) AND (YEAR(CreatedOn)...

  • RE: If Exists UPDATE ELSE INSERT

    The check for existence looks way too complicated - this should work:

    INSERT INTO SERVERS_V

    (

    SERVER_ID,

    SERVER_NAME,

    SERVER_MAKE,

    .

    .

    .

    SERVER_TIMEZONE

    )

    SELECT

    SERVER_ID,

    SERVER_NAME,

    SERVER_MAKE,

    .

    .

    .

    SERVER_TIMEZONE

    FROM SERVERS_VT

    WHERE NOT EXISTS (SELECT 1 FROM SERVERS_V WHERE SERVER_ID = SERVERS_VT.SERVER_ID)

  • RE: How to use IF in designing a view?

    Vasudev Tantry (9/9/2010)


    Thanks Crazy..

    You're welcome, Forum Newbie 😛

  • RE: How to use IF in designing a view?

    Use CASE.

    IF enables you to distinguish between statements, CASE enables you to distinguish between values.

    SELECT

    c.c_fname AS [First Name],

    c.c_lname AS [Last Name],

    c.c_nick_name AS [Emp Id],

    b.b_number_str AS [Card...

  • RE: Enjoy Your Job

    Jack Corbett (9/9/2010)


    ...At the end of the day I want to see that my work is having an impact and if it isn't then that is when I am looking...

  • RE: Enjoy Your Job

    Whether you're permy or contracting, it seems to me that the three KPIs affecting happiness at work are money, people, and the actual work you're doing.

    All three and you're...

  • RE: Searching a part of String in string Column

    chetanr.jain (9/8/2010)


    Hi,

    I require a little help on string query.

    I have two table ( Table A and Table B) each having employee column with string values.

    I want to search that does...

  • RE: Question: float display as character

    Jeff Moden (9/9/2010)


    As a side bar, the "2" option I used in the conversion is the 16 byte option for "E" notation. If I'd used "1", it would have...

  • RE: Question: float display as character

    declare @returnvalue float

    set @ReturnValue = ((6840844991.81 + 113664947.42) - (6947944500.34 + 2417617.57)) / (6947944500.34 + 2417617.57)

    SELECT @ReturnValue --this is the correct calculated float number

    -- truncate to 16dp

    SELECT CONVERT(DECIMAL(26,16),@ReturnValue)

    -- Use...

  • RE: T-SQL code performance - am I missing something obvious

    Surely this would be tons easier and quicker if you were to normalise out the categories quite early on?

    DROP TABLE #Temp

    CREATE TABLE #Temp (ID INT IDENTITY(1,1), Name VARCHAR(30), [Address] VARCHAR(60),...

  • RE: Please help with a query

    WayneS (9/8/2010)


    Chris Morris-439714 (9/8/2010)


    WayneS (9/8/2010)


    Here's my solution. I took a similar approach that Chris did to make a row for each unit, but how we did that is different (I'm...

  • RE: Please help with a query

    WayneS (9/8/2010)


    Here's my solution. I took a similar approach that Chris did to make a row for each unit, but how we did that is different (I'm using a tally...

  • RE: Today's Random Word!

    CirquedeSQLeil (9/8/2010)


    Chris Morris-439714 (9/8/2010)


    CirquedeSQLeil (9/8/2010)


    eep opp ork ah ah

    Like a Richmond sausage, you know there's pork in there somewhere.

    p ork ahhhhhh

    LOL

    You need one of those dandy 360o sofas.

  • RE: Today's Random Word!

    CirquedeSQLeil (9/8/2010)


    eep opp ork ah ah

    Like a Richmond sausage, you know there's pork in there somewhere.

Viewing 15 posts - 7,426 through 7,440 (of 10,144 total)