Forum Replies Created

Viewing 15 posts - 16 through 30 (of 40 total)

  • RE: The Joy of Numbers

    In splitting string using number table is not this approch simpler?

    DECLARE @S VARCHAR(80)='Army,Navy,Air Force,Marines'

    ;WITH c AS

    (SELECT 1 AS n

    UNION ALL

    SELECT n+1 FROM c WHERE n...

  • RE: Invalid length parameter passed to the LEFT or SUBSTRING function.

    Thank you,

    I use ABS() function for solving the problem.

    And put here some solution for splitting string, see:

    SET NOCOUNT ON

    DECLARE @S VARCHAR(8)='kill,ill'

    ;WITH c AS

    (SELECT 1 AS n

    UNION...

  • RE: Pivoting with variable column names

    Try this:

    INSERT INTO TABLERESULT

    SELECT SECTION,

    COURSECODE,

    MAX(CASE WHEN rec_id = 1 THEN ParameterVALUES END) AS P1,

    COALESCE(MAX(CASE WHEN rec_id = 2 THEN ParameterVALUES END), '') AS P2,

    COALESCE(MAX(CASE WHEN rec_id = 3 THEN ParameterVALUES...

  • RE: Dynamic SQL

    Steve Cullen (5/19/2010)


    From OBJECTPROPERTY BOL:

    The Database Engine assumes that object_id is in the current database context. A query that references an object_id in another database will return NULL or incorrect...

  • RE: Dynamic SQL

    I use database name before the INFORMATION_SCHEM view but when I use the USE statement with another database name my result is incorrect.

    I have two database with names "concat" and...

  • RE: Dynamic SQL

    Thank you very much!

  • RE: Comparing spaces characters

    ColdCoffee (5/19/2010)


    Use DATALENGTH function, This will calculate white spaces at both ends of the string. This might help your cause!

    Thanks a lot ColdCoffee! 🙂

    I have not used this function yet.

  • RE: Comparing spaces characters

    I fine the mistake!

    Assume my string is: DECLARE @S VARCHAR(500) = 'abc 'SELECT LEN(@s) --The result will be 3! not 5! This was my problem

    Why SQL Server...

  • RE: CHARINDEX is not Case Sensitive?

    Dave Ballantyne (5/19/2010)


    Or by using a case sensitive collation

    SELECT CHARINDEX('x' collate SQL_Latin1_General_CP1_CS_AS, 'X' collate SQL_Latin1_General_CP1_CS_AS) [/cod]

    Thanks. It is exactly what I was looking for!

  • RE: Comparing spaces characters

    ColdCoffee (5/19/2010)


    You may probably wnat to read thro one excellent article from Jeff Moden on how to "REPLACE Multiple Spaces with One"

    LINK : REPLACE Multiple Spaces with One[/url]

    Hope this helps...

  • RE: CHARINDEX is not Case Sensitive?

    But how about this?

    SELECT CHARINDEX('X', 'abcdx')

    If we want compare just two characters your way is correct. But at this case we cannot do this.

    Can I use something like COLATE in...

  • RE: Problem with a Query

    I got it! 🙂

    select convert(varchar(150),0x202020202020202020202020202020202020202020202020202020202020292020202020202020202020202020202020202020) union all

    select convert(varchar(150),0x202020202020202020202020202020202020202020202020202020202020202820202020202020202020202020202020202020) union all

    select convert(varchar(150),0x202020202020202020202020202020202028202020202020202020202020282029202020202020202020202020202020202020) union all

    select convert(varchar(150),0x202020202020202020202020202020202029202020202020202020202020202220202020202020202020202020202020202020) union all

    select convert(varchar(150),0x202020202020202020202020202020202820292020202020202020202020202020202020202020202020202020202020202020) union all

    select convert(varchar(150),0x202020202020202020202020202020202022202020207C202020202020202020207C2020202020202020202020202020202020) union all

    select convert(varchar(150),0x202020202020202020202020207C20202020202020282820202020202020202020292920202020202020202020202020202020) union all

    select convert(varchar(150),0x202020202020207C2020202020292920202020202029292020202920202020202F2F2020202020202020202020202020202020) union all

    select convert(varchar(150),0x20202020202020292920202028202920202020202F202F202020282020202028202820202020207C2020202020202020202020) union...

  • RE: Problem with a Query

    Lowell (5/18/2010)


    ok, still easy to do...can we assume the query results will be seen in text mode?

    Yes.

  • RE: Problem with a Query

    Thanks, but I am looking for a query that generates the result and we cannot to see the result before running it.

  • RE: Power Set

    Gopi Muluka (5/18/2010)


    Try this

    WITH RecCTE AS

    (

    SELECT Convert(VarChar(30),i) i FROM T

    UNION ALL

    SELECT Convert(Varchar(30),t2.i+','+t3.i) as i FROM T T2

    CROSS JOIN RecCTE T3

    WHERE t2.i<>t3.i AND t2.i<LEFT(t3.i,1)

    )

    SELECT * FROM RecCTE

    ORDER BY LEN(I),i

    Thanks. It seems...

Viewing 15 posts - 16 through 30 (of 40 total)