Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Carriage return

Author  Topic 

bhavna
Starting Member

6 Posts

Posted - 2008-12-12 : 14:09:32
Hi,

I am trying to add carriage return in my function.

But , I am getting space if I use SET @newArray = @newArray + @map_name + Char(13) + Char(10)

I am not sure what's causing the problem. I am using Microsft SQL Server - SQL Editor. I am new to Microsft SQL Server. So, it might be something that I am doing wrong.


ALTER FUNCTION IVR_ADMIN.fnParseArray (@Array VARCHAR(1000),@separator CHAR(1))
RETURNS varchar(8000)
AS
BEGIN
-- @Array is the array we wish to parse
-- @Separator is the separator charactor such as a comma
DECLARE @separator_position INT -- This is used to locate each separator character
DECLARE @array_value VARCHAR(1000) -- this holds each array value as it is returned
-- For my loop to work I need an extra separator at the end. I always look to the
-- left of the separator character for each array value
DECLARE @newArray VARCHAR(8000)
DECLARE @map_name VARCHAR(50)

SET @array = @array + @separator
SELECT @newArray = ''

-- Loop through the string searching for separtor characters
WHILE PATINDEX('%' + @separator + '%', @array) <> 0
BEGIN

-- patindex matches the a pattern against a string
SELECT @separator_position = PATINDEX('%' + @separator + '%',@array)
SELECT @array_value = LEFT(@array, @separator_position - 1)
-- This is where you process the values passed.
--INSERT into map_name
-- Replace this select statement with your processing
-- @array_value holds the value of this element of the array
-- This replaces what we just processed with and empty string
SELECT @map_name = MAP_NAME from IVR_ADMIN.IVR_MAPPING where MAP_ID = @array_value
-- Forming the new array with map_name

SET @newArray = @newArray + @map_name + Char(13) + Char(10)

SELECT @array = STUFF(@array, 1, @separator_position, '')

END

RETURN @newArray
END

Thanks,
-Bhavna

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-12-12 : 14:34:52
use CTRL+T (text mode) to see Carriage returns
Go to Top of Page

bhavna
Starting Member

6 Posts

Posted - 2008-12-12 : 14:44:23
Does not work with CTRL + T
Go to Top of Page
   

- Advertisement -