Forum Replies Created

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

  • RE: Hourly Data and its total

    As I said, the code was untested, because your data was not in an easily consumable format. (It still isn't.) I suggest reading Jeff's article about how to...

  • RE: Need help with SQL Query

    IsNull() is more succinct than the CASE statement.

    IsNull(a.PUser, b.PrimaryUser) AS PUser

    Drew

  • 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...

  • 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

  • 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...

  • 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...

  • 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,...

  • 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

  • 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...

  • 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...

  • 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...

  • 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...

  • 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...

  • 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...

  • 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

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