SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 error declare select
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pascal_jimi
Posting Yak Master

Azerbaijan
139 Posts

Posted - 07/15/2013 :  02:05:44  Show Profile  Visit pascal_jimi's Homepage  Reply with Quote


create table kateqor
(id int not null identity(1,1),
Name nvarchar(50))

insert into kateqor
(Name)
values
(N'M?nzild? qurum')

select*from kateqor



but when I do a query

declare @kat nvarchar(50)
set @kat='M?nzild? qurum'
select * from kateqor where Name=N(@kat)


I receive an error

Post 195, Level 15, state 10, line 4
'N' is not a recognized function name.

kmkmmm

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 07/15/2013 :  02:12:50  Show Profile  Reply with Quote
it should be


declare @kat nvarchar(50)
set @kat=N'M?nzild? qurum'
select * from kateqor where Name=@kat


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs

Edited by - visakh16 on 07/15/2013 02:16:40
Go to Top of Page

pascal_jimi
Posting Yak Master

Azerbaijan
139 Posts

Posted - 07/15/2013 :  02:23:36  Show Profile  Visit pascal_jimi's Homepage  Reply with Quote
thank you visakh

create procedure insert11
@kat nvarchar(50)
as
select * from kateqor where Name=@kat

exec insert11 N'M?nzild? qurum'

but the problem is that I need to send only @kat
without N '


how mak i create proc

execute only @kat

for example

exec insert111 'M?nzild? qurum'


without N'


kmkmmm
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 07/15/2013 :  02:33:31  Show Profile  Reply with Quote
quote:
Originally posted by pascal_jimi

thank you visakh

create procedure insert11
@kat nvarchar(50)
as
select * from kateqor where Name=@kat

exec insert11 N'M?nzild? qurum'

but the problem is that I need to send only @kat
without N '


how mak i create proc

execute only @kat

for example

exec insert111 'M?nzild? qurum'


without N'


kmkmmm


if you need to send value as unicode then you should use N as prefix otherwise it'll interpret it as normal varchar string.

exec insert111 N'M?nzild? qurum'

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000