February 26, 2008 at 1:36 pm
Look up creating a "scalar function". That's a function returning a single value as opposed to returning an entire table.
create function myfunc(@myparams int, ...)
RETURNS @bob int
as
BEGIN
.....
RETURN
END
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
February 26, 2008 at 1:43 pm
thank you Matt
i will do that and let you know how i make out.
February 26, 2008 at 2:04 pm
DECLARE@Sample TABLE (Data VARCHAR(100))
INSERT@Sample
SELECT'str001dt020208reg005trn0001'
SELECTs.Data,
t.*
FROM@Sample AS s
CROSS APPLY(
SELECTSUBSTRING(Data, 1, 6) AS Store,
SUBSTRING(Data, 7, 8) AS Date,
SUBSTRING(Data, 15, 6) AS RegisterNum,
SUBSTRING(Data, 21, 7) AS TransactionNum
) AS t
N 56°04'39.16"
E 12°55'05.25"
February 26, 2008 at 7:45 pm
Ummm... why is Cross-Apply necessary here? Seems to be a bit of overkill when the simple substrings would probably do just fine...
--Jeff Moden
Change is inevitable... Change for the better is not.
February 27, 2008 at 1:19 am
Just in case there are more than piece of information of same type.
I suspect we haven't been told the full picture.
N 56°04'39.16"
E 12°55'05.25"
Viewing 5 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply