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.
| 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)ASBEGIN-- @Array is the array we wish to parse-- @Separator is the separator charactor such as a commaDECLARE @separator_position INT -- This is used to locate each separator characterDECLARE @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 valueDECLARE @newArray VARCHAR(8000) DECLARE @map_name VARCHAR(50) SET @array = @array + @separatorSELECT @newArray = ''-- Loop through the string searching for separtor charactersWHILE PATINDEX('%' + @separator + '%', @array) <> 0 BEGIN -- patindex matches the a pattern against a stringSELECT @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 stringSELECT @map_name = MAP_NAME from IVR_ADMIN.IVR_MAPPING where MAP_ID = @array_value-- Forming the new array with map_nameSET @newArray = @newArray + @map_name + Char(13) + Char(10) SELECT @array = STUFF(@array, 1, @separator_position, '')ENDRETURN @newArrayENDThanks,-Bhavna |
|
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-12-12 : 14:34:52
|
| use CTRL+T (text mode) to see Carriage returns |
 |
|
|
bhavna
Starting Member
6 Posts |
Posted - 2008-12-12 : 14:44:23
|
| Does not work with CTRL + T |
 |
|
|
|
|
|