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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQL Errror: Incorrect syntax near ' '.

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2012-03-22 : 23:35:02
I have a simple select statement which returns the error message below. The ' ' character is not a space, I am not sure what character it is. If I copy the query, paste it into word document, then copy from word and paste back to query analyzer, now the select statement does not return error. Anyone know what is this ' '?

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-22 : 23:37:51
might be an unprintable character like char(10),char(13) etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2012-03-22 : 23:40:07
How to detect this by using sql? I need to scan through all the select statements which are stored in the table.

quote:
Originally posted by visakh16

might be an unprintable character like char(10),char(13) etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-22 : 23:43:28
why are you storing queries themselves as values in table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2012-03-23 : 03:11:14
due to the queries need to be changed very frequent, to make it more flexible, I stored it in table.

quote:
Originally posted by visakh16

why are you storing queries themselves as values in table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-03-23 : 11:31:51
To find out what the character is, you can cast the string to a varbinary and lookup the actual value from an ASCII chart.

Ex.
declare "MyString varchar(100) = 'My string with wierd characters in it'
select cast(@MyString as varbinary(max))

Alternately, if you know the offset of the character (or can iterate through the string), you can use the ASCII function to return the numeric value of the character.
=================================================
It is not so much our friends' help that helps us as the confident knowledge that they will help us. -Epicurus, philosopher (c. 341-270 BCE)
Go to Top of Page
   

- Advertisement -