SQL Server - Equivalent split function

san 222 replied to Umair Imran at 04-Mar-08 05:22

try out this function to get the comma seperated string in the form of table and iterate it in the loop to get each value

FUNCTION getstringintableform (tempstr IN VARCHAR2, separator IN CHAR)

RETURN getstringintableform_temptab

IS

temp getstringintableform_tempobj;

tempstr_ VARCHAR2 (32000) := tempstr;

separator_ CHAR (1) := separator;

separator_position NUMBER (10, 0);

tmptab getstringintableform_temptab

:= getstringintableform_temptab

();

BEGIN

tempstr_ := tempstr_ || separator_;

separator_position := INSTR (tempstr_, separator_);

WHILE separator_position <> 0

LOOP

temp := getstringintableform_tempobj (NULL);

temp.col1 := TRIM (SUBSTR (tempstr_, 1, separator_position - 1));

tempstr_ := SUBSTR (tempstr_, separator_position + 1);

separator_position := INSTR (tempstr_, separator_);

tmptab.EXTEND;

tmptab (tmptab.COUNT) := temp;

END LOOP;

RETURN tmptab;

END getstringintableform;

 

Its in oracle, convert to sqlserver code...

 


Click here to sign in and reply. You could earn money via our message board contest just for being helpful.
  Equivalent split function - Umair Imran  04-Mar-08 05:06 5:06:11 AM
      Equivalent split function - san 222  04-Mar-08 05:22 5:22:05 AM
      parsing the comma seperated values - sundar k  04-Mar-08 05:26 5:26:49 AM
          One Question - Muhammad Deeraf  04-Mar-08 11:07 11:07:14 PM
              comma value alone - sundar k  05-Mar-08 04:36 4:36:48 AM
                  thnx - Umair Imran  05-Mar-08 06:53 6:53:20 AM
          Comma Seperated Values - Jatinder Singh  05-Mar-08 06:57 6:57:05 AM
      Comma Delimited Value to Table - F Cali  04-Mar-08 09:44 9:44:10 AM
View Posts

  

Search

search



Purchase