473,529 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using REPLACE with NCHAR in a stored procedure

I'm using replace in a stored procedure to eliminate carriage returns
a user might have entered in an Access field.
The problem is that even though it seems to strip out the carriage
return I can't get rid of the "□" character.

This is my code:

DECLARE @myReturn nvarchar(1)
SELECT @myReturn = NCHAR(10)

REPLACE(UserAddress,@myReturn,' ') AS myTEXT

For example, the user has entered:

123 Oak Street
Suite 101
What I get after running the replace is: 123 Oak Street □ Suite
101

lq
Jul 20 '05 #1
2 11442
Lauren Quantrell (la*************@hotmail.com) writes:
I'm using replace in a stored procedure to eliminate carriage returns
a user might have entered in an Access field.
The problem is that even though it seems to strip out the carriage
return I can't get rid of the "□" character.

This is my code:

DECLARE @myReturn nvarchar(1)
SELECT @myReturn = NCHAR(10)

REPLACE(UserAddress,@myReturn,' ') AS myTEXT

For example, the user has entered:

123 Oak Street
Suite 101
What I get after running the replace is: 123 Oak Street □ Suite
101


Not really sure what the problem is, but to get rid of CR, pass nchar(13)
as the second argument to replace(), and to get rid of □ pass
nchar(9633):

declare @x nvarchar(200),
@y nvarchar(200)
select @x = 'This is text with char 9633 (' + nchar(9633) +
') and a CR (' + nchar(13) + ')in it.'
select @y = replace(@x, nchar(13), '/')
select @y = replace(@y, nchar(9633), '/')
select @x
select @y
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Erland,
Thanks for your response. If I remove only NCHAR(10) or only NCHAR(13)
I still get the character &#9633 (which is a small square box.) But
thanks to your pointing out NCHAR(13) I am now using the following and
it works to remove both the return and the square box character:

REPLACE(REPLACE(UserAddress,NCHAR(13),''),NCHAR(10 ),'')

Thanks!
lq
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
Lauren Quantrell (la*************@hotmail.com) writes:
I'm using replace in a stored procedure to eliminate carriage returns
a user might have entered in an Access field.
The problem is that even though it seems to strip out the carriage
return I can't get rid of the "□" character.

This is my code:

DECLARE @myReturn nvarchar(1)
SELECT @myReturn = NCHAR(10)

REPLACE(UserAddress,@myReturn,' ') AS myTEXT

For example, the user has entered:

123 Oak Street
Suite 101
What I get after running the replace is: 123 Oak Street □ Suite
101


Not really sure what the problem is, but to get rid of CR, pass nchar(13)
as the second argument to replace(), and to get rid of □ pass
nchar(9633):

declare @x nvarchar(200),
@y nvarchar(200)
select @x = 'This is text with char 9633 (' + nchar(9633) +
') and a CR (' + nchar(13) + ')in it.'
select @y = replace(@x, nchar(13), '/')
select @y = replace(@y, nchar(9633), '/')
select @x
select @y

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1512
by: vaishaliekhar | last post by:
Hello, I have created a stored procedure using SPUFI. The stored procedure is defined to execute an external Assembler routine. There was no error while creating the stored procedure. While calling the stored procedure from a Java program I am getting the following error: Exception: java.sql.SQLException: SQL0444N
2
2898
by: Aragorn | last post by:
I want to load into a SqlCommand objet an existing stored procedure. I know that by using the Parameters collection I can add parameters, but how can I retrieve the parameters already defined from the SP? I would like by a reflection-like mechanisms be able to get the parameters declared into the SP. Strangely, if you're using the Server...
4
2075
by: icebrrrg | last post by:
Hi. I have some functionality in a C# DLL that I would like to be able to call from inside SQLServer. I know this was possible in C++, using an Extended Stored Procedure, but I haven't been able to find a similar process for C#. Does anyone know if such an animal exists? I believe I could call the C# routines from within a C++ extended...
0
979
by: Ing. Rajesh Kumar | last post by:
Hi everybody I have a DECIMAL column with scale = 2. When I insert data into this column from a web page using Stored procedure, the data is rounded up. but when I use a query instead, then things are OK. For example : I want to insert : 24.60 With SP it insert 25 With direct Insert query it insert : 24.60 Why so with SP ? Thanks Raja
12
17618
by: Scott | last post by:
Front-end Access 2000 I have a stored procedure that has 2 parameters BusinessUnitID and Year. It returns multiple record sets (5 to be exact). I thought I could use a Pass through query but that only returns the first record set. I thought I could use ADO but that does not seem to work. I get an Error
1
2682
by: Karthik | last post by:
I'm attempting to call a storedprocedure from within an ActiveX task in a DTS and am getting a "Command Text was not set for the command object" error. I have no problem if I replace the stored procedure call with the actual SQL. Is it possible to directly call a SP via an ActiveX task? If yes, could somebody help me with the syntax please?...
1
2291
by: satish mullapudi | last post by:
Hi, I am using DB2 v8.2 & jdk 1.4. 1. I have a java program which returns an array which contains 1 to 5 numbers. The code: public class ArrayTest { public static final int ARRAY_SIZE = 5; public static int array() {
1
394
by: Venkat | last post by:
Hi, Is there any way to give feedback to the application while a stored procedure execution is in progress? I am using sql server and my application is built using c#. The stored procedure tries to delete around 200K records and there is no way to give the progress of the deletion to the user. Some times i get time out error as it takes...
3
2219
by: sunilkes | last post by:
Hello I am a newbie to this, so I would appreciate any help, I am struggling to get this to work CREATE PROCEDURE . @strfinalint as varchar(1000), @startdate as datetime @enddate as datetime
2
7462
by: Carlton Kirby | last post by:
I need to execute a job on a SQL Express 2005 instance (no SQLAgent). The job will be executed manually by a user, so it doesn't need to be scheduled to run automatically. I thought I could execute the job through a stored procedure, but it appears that SQL Agent is necessary even for that. The job was given to me by a software vendor to...
0
7261
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7498
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7665
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7611
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5799
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
898
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
564
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.