on ‎2016 Oct 03 6:54 PM
Hi Experts,
Is there another function that works exactly like SQL "REPLICATE" function?
Regards
Justice
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Replicate function is working in SQL server. For example, if you run below query,
SELECT REPLICATE( ' Nagarajan ' , 2 )
Result is, Nagarajan Nagarajan
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Diego,
My SQL has the replicate function. What is happening is I want an alternative to this function because I used it to created a query in SAP Business UDF query and it works perfectly.
Unfortunately SAP Business One version for HANA does not have the replicate function and became of that I can't apply the query in the UDF query .
If there's an alternative function that also works in both SAP Business one version for SQL and HANA I will be glad if that can be shared .
Regards
Justice
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Justice,
With this approach, I just know REPLICATE() function, but if this function is not available in your sql server version, you can build your own function to replicate data.
CREATE FUNCTION myReplicate(@value nvarchar(max), @length int)
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @count int = 0
DECLARE @return varchar(MAX) = ''
WHILE(@count < @length)
BEGIN
set @count = @count + 1
set @return = @return + @value
END
RETURN @return
END
And after you create the function in your database, you can call like this:
SELECT dbo.myReplicate('a', 2)
Hope it helps.
Best regards,
Diego Lother
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 55 | |
| 29 | |
| 21 | |
| 10 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.