SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sql Server 2000; replicate() & space()

    OK, people, try this...
    Code:
    create table table1
    (
    	col1 char(10) collate Finnish_Swedish_CI_AS null,
    	col2 char(10) collate Finnish_Swedish_CI_AS null
    )
    
    insert table1 values('blah', 'blah')
    
    select col1 + replicate(' ', 10) + col2
    from table1
    select col1 + space(10) + col2
    from table1
    
    drop table table1
    ...and then count the number of spaces between blah and blah
    (assuming your db's collation isn't Finnish_Swedish, if it is Finnish_Swedish, then use Latin1_General or something for the columns)

    Is this weird or what?

  2. #2
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Er, well what I get in BOTH cases is two "blah" substrings separated by seven (yes, 7) spaces....!????
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  3. #3
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which is 'blah      ' + ' ' + 'blah      '
    (Remember: col1 is char(10))
    I.e. space() and replicate() returns only one(1) space

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DOH! Going back to bed....
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •