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
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Adding symbol(%) in store procedure
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sql4us
Starting Member

24 Posts

Posted - 03/13/2013 :  14:27:40  Show Profile  Reply with Quote
Hi All,

I want to know how to add percentage symbol(%) to my final sql statment, it should look below

set @finalSelect = 'SELECT NAME,State,TotalPop, ' + @parameter +'_Pop%
FROM
'

Result: NAME, State, TotalPop, White_Pop% (column names)


When I add % symbol it throws an error:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '%'.

Any idea how to add percentage(%) symbol??

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 03/13/2013 :  14:52:11  Show Profile  Visit webfred's Homepage  Reply with Quote
is it part of a column name? then the column name should be for example in square brackets [White_Pop%]

otherwise please explain more clear what you are trying to do...


Too old to Rock'n'Roll too young to die.
Go to Top of Page

sql4us
Starting Member

24 Posts

Posted - 03/13/2013 :  15:00:30  Show Profile  Reply with Quote
Thanks for your reply webfred.
No, its not part of the column name.
My final sql statement:
set @finalSelect = 'SELECT NAME,State,TotalPop, result as White_pop%
FROM
'

Here the column name "result" I want to call as "White_Pop%". Some how other symbols like Income($) it works fine but when I use % symbol it throws me an error.



quote:
Originally posted by webfred

is it part of a column name? then the column name should be for example in square brackets [White_Pop%]

otherwise please explain more clear what you are trying to do...


Too old to Rock'n'Roll too young to die.

Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8679 Posts

Posted - 03/13/2013 :  15:03:02  Show Profile  Visit webfred's Homepage  Reply with Quote
use square brackets and it will work

result as [White_pop%]


Too old to Rock'n'Roll too young to die.
Go to Top of Page

sql4us
Starting Member

24 Posts

Posted - 03/13/2013 :  15:13:22  Show Profile  Reply with Quote

Thanks webfred :) It did work.

quote:
Originally posted by webfred

use square brackets and it will work

result as [White_pop%]


Too old to Rock'n'Roll too young to die.

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.06 seconds. Powered By: Snitz Forums 2000