i know its not possible, but i really need to return a string from a stored procedure (or something else)...
I am using PHP on an 2k server, all is good working fine...
I use SQL stored procedures to insert data into a database but recently encountered a minor problem that i couldn't execute more than one line of code at one time or PHP could not connect to the db for the rest of the page...
I worked out that stored procedures were the way to go and wrote several with little effort.
I am now trying to split up a string by a character and use the parts as fields in the database.
However, I cannot find a way to get the string the sp genereates back to the main sp...
here is the sp:
CREATE PROCEDURE [dbo].[split_str] (@str as varchar, @param as char(1), @part as int) AS
Declare @last int, @pos int, @found int
set @last = 1
set @pos = 0
set @found = 0
set @str = @str + @param
WHILE @pos <= LEN(@str)
BEGIN
set @pos = @pos + 1
if (ascii(substring(@str,@pos,1)) = ascii(@param))
BEGIN
set @found = @found + 1
if (@found = @part)
print substring(@str,@last,@pos-@last)
set @last = @pos + 1
END
END
if (@found = (@part - 1))
print substring(@str,@last,@pos-@last)
GO
I thought about trying prints, but to no avail... i also tried return, but it only does ints...
Please help as this is really really bugging me!
thx
I am using PHP on an 2k server, all is good working fine...
I use SQL stored procedures to insert data into a database but recently encountered a minor problem that i couldn't execute more than one line of code at one time or PHP could not connect to the db for the rest of the page...
I worked out that stored procedures were the way to go and wrote several with little effort.
I am now trying to split up a string by a character and use the parts as fields in the database.
However, I cannot find a way to get the string the sp genereates back to the main sp...
here is the sp:
CREATE PROCEDURE [dbo].[split_str] (@str as varchar, @param as char(1), @part as int) AS
Declare @last int, @pos int, @found int
set @last = 1
set @pos = 0
set @found = 0
set @str = @str + @param
WHILE @pos <= LEN(@str)
BEGIN
set @pos = @pos + 1
if (ascii(substring(@str,@pos,1)) = ascii(@param))
BEGIN
set @found = @found + 1
if (@found = @part)
print substring(@str,@last,@pos-@last)
set @last = @pos + 1
END
END
if (@found = (@part - 1))
print substring(@str,@last,@pos-@last)
GO
I thought about trying prints, but to no avail... i also tried return, but it only does ints...
Please help as this is really really bugging me!
thx