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.
Author |
Topic |
jp2code
Posting Yak Master
175 Posts |
Posted - 2010-02-01 : 17:03:49
|
I've got a query I've been working with to create a windows form application that joins two tables. It runs fine, so I inserted the query's text to debug into my application to see how my values populate into my fields.When I run my application, I get this unhelpful message: quote: SqlClient.SqlError MessageIncorrect syntax near 'm'.
Here is my query that runs without issue in Management Studio:SELECT m.ID, m.[Group], m.Dept, m.Shift,e.Firstname+' '+e.Lastname as 'Manager', m.MgrNum, m.ScheduleFROM ShiftManage m INNER JOIN Employees e ON (m.MgrNum=e.Num) Employees::Num is a nvarchar(255) to hold a 6 digit badge numberwhereas my newly created table hasShiftManage::MgrNum is a nvarchar(10)In some cases, the ShiftManage::MgrNum can be NULL. This indicates "no manager" - but the query in Management Studio works.Why does Visual Studio (2008 Pro) fail?Thanks for your time,~Joe Avoid Sears Home Improvement |
|
Kristen
Test
22859 Posts |
Posted - 2010-02-01 : 17:08:43
|
Maybe it is trying to do some parsing for you?Long shot: but perhaps changing toFROM ShiftManage AS m |
|
|
jp2code
Posting Yak Master
175 Posts |
Posted - 2010-02-01 : 17:15:43
|
Nope. That didn't fix it.I can get around it easy enough: I dropped it into a stored procedure, and it works great. Still, I'd like to know what's going on under the hood. Avoid Sears Home Improvement |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-02-01 : 17:22:35
|
Might be worth running SQL Profiler and seeing what is actually being sent to SQL ... your syntax may be getting mangled somewhere along the way. |
|
|
jp2code
Posting Yak Master
175 Posts |
|
|
|
|
|
|