Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tsql update... fails in code, but works in SSMS editor? 1

Status
Not open for further replies.

markgrizzle

Programmer
Aug 3, 2003
288
US
Hi Everyone,
My program is failing so I stepped through my asp/vb.net method and copy/paste/parsed the content below from my string variable into the query window;

update data set affiliated_unit = account_code 
where company = 'US - Charleston Place Hotel'
and account_code in (select account_code from intercompany_account
where property = 'US - Charleston Place Hotel') 

The parser generates this error:

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

But if I manually type the same statement and parse it, it succeeds.

update data set affiliated_unit = account_code
where company = 'US - Charleston Place Hotel'
and account_code in (select account_code from intercompany_account
where property = 'US - Charleston Place Hotel')

"Command(s) completed successfully."

I've been going in circles trying to understand this. Has anyone seen this before?

Thanks in advance,
Mark

ps - My environment is listed below (copied from the About SQL Server dialog)

Microsoft SQL Server Management Studio 9.00.4035.00
Microsoft Analysis Services Client Tools 2005.090.4035.00
Microsoft Data Access Components (MDAC) 6.0.6002.18005 (lh_sp2rtm.090410-1830)
Microsoft MSXML
3.0 6.0
Microsoft Internet Explorer
8.0.6001.18975
Microsoft .NET Framework
2.0.50727.4206
Operating System
6.0.6002
 
Is it possible that the statement has some unprintable characters which invalidate the statement. I suggest to re-type it in the application or paste the version which was successfully parsed instead of what you currently have.

PluralSight Learning Library
 
Hi Markros,
retyping the statement did the trick. I guess something got corrupted when I moved the solution from my winXP setup?

Thanks again for the quick response,
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top