Viewing 15 posts - 331 through 345 (of 375 total)
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]
January 16, 2006 at 6:35 am
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]
January 13, 2006 at 7:08 am
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]
January 13, 2006 at 6:39 am
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]
January 13, 2006 at 6:37 am
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]
January 13, 2006 at 6:30 am
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]
January 12, 2006 at 10:55 am
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]
January 12, 2006 at 10:41 am
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]
January 12, 2006 at 10:32 am
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]
January 12, 2006 at 10:27 am
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]
January 11, 2006 at 2:06 pm
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]
January 11, 2006 at 2:00 pm
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]
January 11, 2006 at 10:18 am
Try SUM( DISTINCT rmstranamt) instead of SUM(rmstranamt)
---------------------------------------------
[font="Verdana"]Nothing is impossible.
It is just a matter of time and money.[/font]
January 11, 2006 at 9:42 am
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]
January 11, 2006 at 6:53 am
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]
January 10, 2006 at 8:53 pm
Viewing 15 posts - 331 through 345 (of 375 total)