Insert with special charactrs

Posted by Venkatesh under Sql Server on 5/18/2012 | Points: 10 | Views : 10074 | Status : [Member] | Replies : 10
Hi,

I am inserting an article into db. One column set nvarchar(max) datatype.
This article contains special characters.When i inserted into table i am getting error at special character.So, how to insert this with special character.

Thanks,
Venkatesh.P




Responses

Posted by: Meet1424 on: 5/18/2012 [Member] Starter | Points: 25

Up
0
Down
use parameters to pass the values to db. It will work properly. u can use parametrized insert statements or procedures to solve your issue.

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pandians on: 5/18/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi

Not sure whether my understanding is correct/not

If you want to Insert a file/document into a table, Kindly use VARBINARY(MAX) type for that column (for an Object)

If you want to Insert a test into a table, Kindly use NVARCHAR(MAX) type for that column. and use N'<special characters>' when inserting data.


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 5/19/2012 [Member] Starter | Points: 25

Up
0
Down
create table emp(empname nvarchar(899))

insert into emp values('sdsds$!@$#$$')

select * from emp

Hope this i will help

Regards
Sriram.R

sriram

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ajay.Kalol on: 5/21/2012 [Member] Starter | Points: 25

Up
0
Down
Put N'<special characters>'

when you inserting value in Table.

N stands for NVARCHAR datatype

Ajay
ajaypatelfromsanthal.blogspot.in

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/15/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

CREATE TABLE app1(id integer,Name nvarchar(max))

INSERT INTO app1(id,Name)
SELECT 1,'MEENU'

UNION ALL SELECT 2,'MANU1'
UNION ALL SELECT 3,'sHY!@#'
UNION ALL SELECT 4,'ka%^&*()'
UNION ALL SELECT 5,'LO)_+?><'
UNION ALL SELECT 6,'BO~&^%$'

SELECT * FROM APP1

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/15/2012 [Member] Bronze | Points: 25

Up
0
Down
Hope you understand it.
Mark as Answer if its helpful to you...

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/15/2012 [Member] Silver | Points: 25

Up
0
Down
You need the N before the string constant to make it Unicode

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/15/2012 [Member] Silver | Points: 25

Up
0
Down
Or u can try like this
http://www.codeproject.com/Questions/157918/How-can-I-insert-a-special-character-in-sql-server

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/23/2012 [Member] Silver | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muralidosscm on: 6/25/2012 [Member] Starter | Points: 25

Up
0
Down
create table mmm(name varchar(max))

insert into mmm values('dasda453534%%%%')
insert into mmm values('dasda4535@#34%%%%')
insert into mmm values('dasda453534##%%%%')
insert into mmm values('dasda453&&534%%%%')


select * from mmm

Regards
Muralidoss M

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response