|
<< Click to Display Table of Contents >> Navigation: iVend Database Database > User Defined Functions > fnSplitValues User Defined Function |
Navigation: iVend Database Database > User Defined Functions >
iVend 6.6 Database Help
fnSplitValues User Defined Function
Collapse All Expand All
iVend Database Database : fnSplitValues User Defined Function |
Properties
Creation Date |
6/28/2017 11:56 AM |
Encrypted |
|
Ansi Nulls |
|
Parameters
Parameter |
Direction |
Description |
Data Type |
Size |
@String |
In |
|
VarWChar |
1073741823 |
@TABLE_RETURN_VALUE |
Return Value |
Result table returned by table valued function |
Empty |
0 |
Objects that depend on fnSplitValues
|
Database Object |
Object Type |
Description |
Dep Level |
|
Stored Procedure |
|
1 |
|
|
Stored Procedure |
|
1 |
|
|
User Defined Function |
|
1 |
|
|
User Defined Function |
|
1 |
|
|
User Defined Function |
|
1 |
Procedure Source Code
CREATE FUNCTION [dbo].[fnSplitValues] ( @String nvarchar(max) ) RETURNS @SplitTable TABLE ( DataString Nvarchar(Max) ) /* CREATED : Jyotsna Tyagi CREATED DATED : 28th Feb, 2017 MODIFED : Jyotsna Tyagi MODIFED DATED : 11th Apr, 2018 DECSRIPTION : To Split multiple filter parameter and avoid Like operator. */ AS BEGIN Declare @DataValue NVARCHAr(max), @Amp Nvarchar(Max) SET @Amp = CONVERT(nvarchar(max), (SELECT @String FOR XML PATH('')), 1) Set @DataValue=CASE WHEN LEN(@Amp)=0 THEN '' ELSE Replace(Left(Right(COALESCE(LTRIM(RTRIM(@Amp)),''), Len(COALESCE(LTRIM(RTRIM(@Amp)),''))-1), Len(Right(COALESCE(LTRIM(RTRIM(@Amp)),''), Len(COALESCE(LTRIM(RTRIM(@Amp)),''))-1))-1),N'☺',',')END DECLARE @xml xml SET @xml = '<r>' + replace(COALESCE(@DataValue,''),',','</r><r>') + '</r>' INSERT INTO @SplitTable(DataString) SELECT r.value('.','Nvarchar(max)') FROM @xml.nodes('/r') as records(r) RETURN END |
See Also
© 2019 All Rights Reserved.
Send comments on this topic.