Forum Replies Created

Viewing 15 posts - 5,551 through 5,565 (of 6,036 total)

  • RE: CASE statement or UDF?

    There is NULLIF system function for your service.

    See BOL for details.

  • RE: need help with a function

    Sorry, no dynamic SQL in UDF.

    But how many tables with personal details you have in your database?

    If you did right design it must be only one.

    If your design in...

  • RE: Returning multiple resultsets from the same table

    If you really need it this way it must be WHILE loop or a cursor.

  • RE: Need Help With SQL For Calculating Time Worked

    Select

    @StartTime = convert(datetime, RecvdDate + ' ' + RecvdTime),

    @EndTime = convert(datetime, ClosedDate + ' ' + ClosedTime)

    SELECT @TimeSpent = datediff(n, @StartTime, @EndTime)/60.0

    If you need seconds precision,

    SELECT @TimeSpent = datediff(ss,...

  • RE: Returning multiple resultsets from the same table

    What do you mean "return each group as a seperate resultset"?

    Return to where? And from where?

  • RE: Can I not use CREATE VIEW in a DTS package or sp?

    This works:

    CREATE table #tblARData  (site int)

    insert #tblARData values(1)

    insert #tblARData values(2)

    insert #tblARData values(2)

    insert #tblARData values(3)

    declare @tblARDataTemp table (site int)

    insert @tblARDataTemp values(1)

    insert @tblARDataTemp values(1)

    insert @tblARDataTemp values(2)

    DELETE FROM #tblARData

    WHERE EXISTS (

      SELECT...

  • RE: Stored Proc advice - avoiding duplicates

    Even easier:

    INSERT into tbl_hp_customers

    (CustomerFirstName,CustomerSurname,TelephoneDay,TelephoneEvening,EMailAddress,OwnerID)

    SELECT 

    SUBSTRING(Enq_CustName, 1, NULLIF(CHARINDEX(' ', Enq_CustName) - 1, -1)) 

    SUBSTRING( Enq_CustName, CHARINDEX(' ', Enq_CustName) + 1, LEN( Enq_CustName))

     , Enq_CustPhone1, Enq_CustPhone2, Enq_CustEMail, @HWID

    FROM tbl_hp_enquiry

    WHERE Enq_ID = @EnquiryID

    AND NOT...

  • RE: Returning Rowcount from a Function

    IMHO, the best way to pass a table to SP or UDF is to create table #<SP(UDF)_Name>, populate it with data and use it inside of SP or UDF.

    But don't forget...

  • RE: Current Date minus one???

    Are you sure?

    What about this?

    SELECT

    DATE_STAMP_ "Date_Time",

    CONVERT(decimal(19,4), DATA_VALUE_)) "Value"

    FROM TRENDDATA AS T1

    WHERE

    DATA_VALUE_ = (SELECT MAX(DATA_VALUE_)

    ...

  • RE: Decimal Rounding. Am I being silly..?

    You are having problem because of implicit conversions.

    Declare variables for original values, assign those values and than start calculations.

    Otherwise all you numbers will be implicitly converted to type real or...

  • RE: Current Date minus one???

    Don't agree with what?

    If to assign:

    SET @StartDate = '2006-02-27'

    SET @EndDate = '2006-02-28'

    then

    BETWEEN @StartDate AND @EndDate

    will actually take records for 2 days, not one, if no time portions recorded...

  • RE: Expanding Hierachies newbie help please

    There is an article on home page of this site.

  • RE: Insert Statement w/ max

    select

                    A.FacId,

      max(A.PunchDT) as MaxPunchDT

     from FacIds A

     group by A.FacId

  • RE: Full outer join

    Select A.Field1, A.Field2, B.Field2

    FROM A

    Left JOIN B on A.Field3 = B.Field1

    GROUP BY A.Field1, A.Field2, B.Field2

  • RE: Conditional Syntax

    select ..., CASE when OwnContact = 'Y' and RevenueTotal < 40000 then 30 when OwnContact = 'Y' and RevenueTotal between 40 and 50000 then 35 Else 40 as Rate, ...

Viewing 15 posts - 5,551 through 5,565 (of 6,036 total)