Forum Replies Created

Viewing 15 posts - 3,796 through 3,810 (of 4,085 total)

  • RE: CASE in WHERE clause

    shank-130731 (1/15/2011)


    What's wrong with my thinking below?

    If @ID is provided, I want the WHERE clause to only reflect ID=@CaseID. If not provided then just RMARequestedDate > (GetDate()- @d).

    WHERE CASE @ID

    WHEN...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Conversion failure in custom sort

    Doesn't the following give you want you want?

    ORDER BY Sort, Type

    If not, something similar should give you the desired results.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Hourly Data and its total

    David's approach will work if you're only reporting on a single day, but immediately runs into problems when reporting on multiple days. A much better approach when you're reporting...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Passing a field reference into the where clause

    The problem is that your SET expression is returning text, not a column name. If you want to return a column you should rewrite your query as follows:

    SELECT top...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Trigger to fire on user basis

    An update trigger will always fire when the table is updated. That is the nature of triggers.

    If you want to control the behavior of the trigger based on userid,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Problem with Bit DataType in Where Clause

    There is a much simpler way using COALESCE.

    SELECT *

    FROM #M_Vendor

    WHERE Coalesce(@imported, DailySettlementYN, -1) = Coalesce(DailySettlementYN, -1)

    The -1 forces an implicit conversion of the bit data.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Nested XML Explicit encodes the xml to string

    nikshepmehra (12/7/2010)


    Thanks I tired it with the type keyword and tried to cast the string as xml type

    But the query gave an error as

    "The xml data type cannot be...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Alter View from Trigger Hangs

    Craig Farrell (12/7/2010)


    Run this sample, it'll show you what I mean. GO cannot be part of the proc.

    I know what YOU mean. What I mean is

    CREATE PROC TEST_THIS

    AS

    DECLARE...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Alter View from Trigger Hangs

    Craig Farrell (12/7/2010)


    drew.allen (12/7/2010)


    I was trying to do the same thing and ran into the same problem. The cause was a GO statement that I included in my dynamic...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Alter View from Trigger Hangs

    I was trying to do the same thing and ran into the same problem. The cause was a GO statement that I included in my dynamic SQL. The...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to create procedure from definition of another procedure

    scott.pletcher (11/30/2010)


    Since OBJECT_DEFINITION returns an NVARCHAR(MAX), I would expect it to be able to return up to 2G - 1 (or roughly 1 billion visible characters).

    I've never had any issue...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to create procedure from definition of another procedure

    Information_Schema.Routines will only return the first 4000 characters of your stored procedure. If there is any chance at all that your stored proc is longer than that, you'll probably...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Using Case or If Else statements within joins

    Is this what you are looking for?

    select vendaddr.name

    from vendaddr

    inner join vendor

    on IsNull(vendor.vend_num, vendor.vend_remit) = vendaddr.vend_num

    It will use the vendor_num if it is not null and will use the vend_remit otherwise.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Datetimme Stamp

    Given the data points for the date, it looks like the base date is 1899-12-30. The time is harder to determine, because you haven't given us enough data points....

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Query with Performance Issues

    I also notice that you are missing some indices that might help. For example, Oilchange_Notes is missing an index on vehicle_id. Since that is used in your join,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 3,796 through 3,810 (of 4,085 total)