Forum Replies Created

Viewing 15 posts - 331 through 345 (of 375 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...

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

  • RE: Need help with Stored Procedure -

    PS.

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

     

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

  • RE: SUM problem

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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

    ---------------------------------------------
    [font="Verdana"]Nothing is impossible.
    It is just a matter of time and money.[/font]

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