Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2008
    Posts
    3

    Unanswered: sql function help

    i have a table with varchar2 data time column which have values in below form

    (123, 445, 564) or (445,123,564)

    i want to capture only 123 part from above values in one sql statement and for this kindly guide me how to achieve this?

    thanks,

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Oracle ?

  3. #3
    Join Date
    Apr 2008
    Posts
    3
    sql server

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    There is no varchar2 data type in SQL Server.

    In your example, are those two rows or one? Are the parentheses part of the data?
    What do you mean by "capture"?

  5. #5
    Join Date
    Apr 2008
    Posts
    3
    these two type of values are in same column and without parenthesis. capture mean get, I want to get specific string which i mentioned earlier.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Well this satisfies the request, but I don't think it is really what you mean:
    Code:
    DECLARE @text_to_capture AS VARCHAR/*2*/ = '123'
    
    SELECT captured = @text_to_capture
    FROM da_table
    WHERE varchar2_column LIKE '%' + @text_to_capture + '%'

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    BTW - are you familiar with first normal form? Because you should not be storing your data like that.

Posting Permissions

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