Forum Replies Created

Viewing 15 posts - 181 through 195 (of 355 total)

  • RE: Multiple values in a CASE

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

  • RE: Multi Column Sort

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

  • RE: Multi Column Sort

    Christian Buettner (4/2/2009)


    Not sure what this is all about, but is this something you would expect?

    SELECT *

    , (SELECT COUNT(*) FROM b

    WHERE ISNULL(col1,0) <= ISNULL(al.col1,9)

    AND ISNULL(col2,0) <= ISNULL(al.col2,9)

    AND...

  • RE: Multi Column Sort

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

  • RE: How to make range for date and count?

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

  • RE: Converting numbers into time format

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

  • RE: Converting serial numbers into time format

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

  • RE: query to show even and odd order

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

  • RE: Constraint conundrum

    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

    ...

  • RE: results of select as variable???

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

  • RE: query to show even and odd order

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

  • RE: query to show even and odd order

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

  • RE: query to show even and odd order

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

  • RE: Adding duplicate rows to a resultset

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

  • RE: Equal Distribution of Office Assignments?

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

Viewing 15 posts - 181 through 195 (of 355 total)