Forum Replies Created

Viewing 15 posts - 331 through 345 (of 374 total)

  • RE: Question regarding NULLS

    Maybe this approach can help.

    To get a three value comparison on a BIT filed that can have NULLs use the CAST and ISNULL functions.

    ISNULL(CAST(col0 AS TINYINT,2) = ISNULL(CAST(col1 AS TINYINT),2) this...

  • RE: GETDATE -> only DATE needed

    Convert works both ways with the format.

    CONVERT(char(8),YourDate,112)   - to convert to CHAR .

    CONVERT(YourDate, char(8),112)  - to convert it...

  • RE: Need help with Stored Procedure -

    PS.

    I love the ISNULL function. In my opinion the coolest introduction to SQL Server.

  • RE: Need help with Stored Procedure -

    CREATE PROCEDURE test

    @LastName VARCHAR(20) NULL,

    @FirstName VARCHAR(20) NULL,

    @DOB DATETIME NULL,

    @Phone VARCHAR(10) NULL

    AS

    SELECT *

    FROM Customer

    WHERE LastName = ISNULL(@LastName, LastName)

    AND FirstName = ISNULL(@FirstName, FirstName)

    AND DOB = ISNULL(@DOB, DOB)

    AND Phone = ISNULL(@Phone, Phone)

     

    The only problem...

  • RE: Question regarding NULLS

    You can not have any alternate value that will behave like NULL. You probably can work on some workaround that will compare one specific value of each data type and...

  • RE: UserDefinedFunction

    Out of curiosity.

    Did you check syscomments text for both functions to verify they are absolutelly the same?

    The second function, did you just copied and pasted the code into...

  • RE: Result needed in a specific format

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=249767

     

    Check this one and look at David's post (the last one). Depending on your data you may have to modify this to fit your needs but it should point...

  • RE: Updating multi tables within a cursor

    You can do this in one cursor. Technically it is possible. The question is why to use cursor in the first place. Check if a SQL without a cursor can do...

  • RE: problem using getdate() in "where" clause

    PW, "Yes, but you don't need that user-defined function", true. The functions was provided because of Kenn's "I want to totally ignore time and only look at the date"....

  • RE: problem using getdate() in "where" clause

    CREATE FUNCTION dbo.fn_DateOnly(@date DATETIME)

    RETURNS DATETIME

    AS

    BEGIN

     RETURN DATEADD(day, DATEDIFF(day, 0, @date), 0)

    END

    and use this in your WHERE

    WHERE DATEDIFF(day, dbo.fn_DateOnly(ARJOBHD.INVDATE), dbo.fn_DateOnly(GETDATE())) = 10

    I hope did not mess up the syntax again...

     

  • RE: SUM problem

    I don't really know what the final product of you query should be. You should post table definitions and sample data (CREATE statement and all INSERT statements) so we can run some...

  • RE: SUM problem

    Please check the sample below:

    CREATE TABLE test2

    (

    testkey  INT,

    testAmt  DECIMAL(7,2)

    )

    GO

    INSERT INTO test2 (testkey, testAmt) VALUES (10, 3265.12)

    INSERT INTO test2 (testkey, testAmt) VALUES (10, 3265.12)

    INSERT INTO test2 (testkey, testAmt) VALUES (10, 3000.50)

    INSERT INTO test2...

  • RE: SUM problem

    Try SUM( DISTINCT rmstranamt) instead of SUM(rmstranamt)

  • RE: 24hr Time Format

    You are right SQLBill but what I am pointing out is the fact that you can use the format not only when converting into VARCHAR but when converting back to...

  • RE: 24hr Time Format

    The nice thing about the CONVERT is the fact that you can use the format parameter when you convert from (VAR)CHAR into (SMALL)DATETIME.

    For example if you have a string...

Viewing 15 posts - 331 through 345 (of 374 total)