Viewing 15 posts - 181 through 195 (of 355 total)
Does either of the following queries do what you require?
SELECT * FROM table
WHERE (@somevar <> '111' AND field = CONVERT(int, @somevar))
OR (@somevar = '111' AND field...
April 6, 2009 at 9:50 am
Bob,
Regardless of whether the data type is integer or decimal, I don't think your solution works. I think the only solution so far posted that works correctly is Christian's.
From what...
April 2, 2009 at 6:56 pm
Christian Buettner (4/2/2009)
SELECT *
, (SELECT COUNT(*) FROM b
WHERE ISNULL(col1,0) <= ISNULL(al.col1,9)
AND ISNULL(col2,0) <= ISNULL(al.col2,9)
AND...
April 2, 2009 at 3:34 pm
This is a hard problem to solve with SQL, and there is also no guarantee of an unambiguous sort order.
e.g.
row col1 col2
---- ---- ----
R1 1.0 2.0
R2...
April 2, 2009 at 12:59 pm
Your problem may be due to the single quotes in the T-SQL within the @query parameter. To fix this problem you have to double up each single quote character that...
April 1, 2009 at 2:00 pm
kylecm2001,
That was my solution from this thread
http://www.sqlservercentral.com/Forums/Topic685851-338-1.aspx
If you were having problems implementing my solution why didn't you reply to the original thread rather than create another here? I've checked all...
April 1, 2009 at 6:33 am
The previous solution from arun.sas won't work properly since you can't treat times stored like this as simple decimal values with respect to addition or subtraction. Also, I understand that...
March 30, 2009 at 3:33 am
I'm a littel disappointed that no one wanted to play.
I think this is in the spirit of that thread. I'm quite pleased to have found a new use for the...
March 27, 2009 at 4:25 pm
Here's an alternative for the check constraint
[font="Courier New"]ALTER TABLE TestName
ADD CONSTRAINT ValueInRange CHECK (
(field_Name BETWEEN 0.0 AND 10.0) AND
...
March 27, 2009 at 3:13 pm
newbie_new (3/26/2009)
Is there any way to get a @variable to work as a table name?i.e.
Select * from @tablename
Yes, you can do this with dynamic SQL, but unless you are...
March 26, 2009 at 5:43 pm
In our example queries it is only really the ORDER BY clause that is relevant to your requirement. Since you didn't provide the structure of your table, we used a...
March 26, 2009 at 3:54 pm
Both queries complete without an error, but negative numbers are returned in normal order.
However, it's probably just an academic point, and not relevant to the OP.
[font="Courier New"]-10
-9
-8
-7
-6
-5
-4
-3
-2
-1 ...
March 26, 2009 at 2:34 pm
Here's a slightly different alternative that works for positive integers and is probably marginally faster. It doesn't work for negative integers.
SELECT number
FROM dbo.Numbers
WHERE number between 1 and 10
ORDER BY (number...
March 26, 2009 at 1:59 pm
You should use a Tally (or Numbers) table for this. There are several articles about Tally tables on this site. You can join to your table to a Tally...
March 24, 2009 at 2:58 pm
This solution should work for any number of records and any number of offices where the number of records is greater than or equal to the number of offices and...
March 24, 2009 at 2:09 pm
Viewing 15 posts - 181 through 195 (of 355 total)