Error Code 102 Sql Server
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more
Microsoft Sql Server Error 102
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges msg 102 in sql server Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each
Mensagem 102 Sql Server
other. Join them; it only takes a minute: Sign up SQL Server : Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '=' up vote 4 down vote favorite I'm writing a stored procedure and I'm sqlserver error 102 passing the table names as parameters, but I'm having an error in this part: DECLARE @TableA nvarchar(255)='TableA', @DOCID1 nvarchar(MAX), @DOCID2 int; EXEC (' SELECT TOP (1) '+ @DOCID1 +'=DOCID1,'+ @DOCID2 +'=DOCID2 FROM [' + @TABLEA + '] ORDER BY DOCID2') After I run this query I get this error: Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '=' I have tried and I can't pinpoint the error, at this point I need some help.. sql sql error 102 incorrect syntax near sql-server sql-server-2008 share|improve this question edited Nov 27 '13 at 6:02 marc_s 452k938641029 asked Nov 27 '13 at 5:47 RicEspn 39137 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted I believe you have to concatenate together your SQL statement as a whole, before executing it: DECLARE @TableA nvarchar(255)='TableA', @DOCID1 nvarchar(MAX), @SqlStmt NVARCHAR(500), @DOCID2 int; SET @SqlStmt = N'SELECT TOP (1) ' + @DOCID1 + N' = DOCID1, ' + @DOCID2 + N' = DOCID2 FROM [' + @TABLEA + N'] ORDER BY DOCID2'; EXEC (@SqlStmt) As far as I recall, you cannot have expressions and computations inside the EXEC command - get the statement prepared before hand, then execute it Also, I'm not entirely sure what those variables of yours hold - @DocID1 and @DocID2 - do you want to set their value, or do they hold the name of another variable to set?? Update: if you actually wanted to set the values of @DocID1 and @DocID2, then your query was wrong to begin with - then you need something like this: DECLARE @TableA nvarchar(255) = 'TableA', @SqlStmt NVARCHAR(500); SET @SqlStmt = N'DECLARE @DocID1 NVARCHAR(MAX), @DocID2 INT; ' + N'SELECT TOP (1) @DOCID1 = DOCID1, @DOCID2 = DOCID2 FROM [' + @TABLEA + N'] ORDER BY DOCID2'; EXEC (@SqlStmt) but then, those two variables are scoped inside the dynamically executed SQL and aren'
... 10 Oct: Strange 1-Time Connect and then I have ... 09 Oct: Heidi duplicate row when i add new 08 Oct: Cross apply 08 Oct: HeidiSQL + SQLite 08 Oct: Title bar buttons flicker in Windows
Incorrect Syntax Near '/'. Sqlstate 42000 (error 102)
10 07 Oct: Help with query 07 Oct: Postgres tree 07 Oct: error code 102 sql state 42000 incorrect syntax near Feature Request 07 Oct: Revision 4514 "Donate" button(s) 07 Oct: UI bug in window: User Manager? 06 Oct: ERROR: syntax
Error 102 In Sql Server 2008
error at or near "DETERMI ... 06 Oct: Crash when accessing database tab. 06 Oct: php query 06 Oct: Help.. lost connection to mysql server ... 06 Oct: Bug: Crash showing tooltip http://stackoverflow.com/questions/20234841/sql-server-msg-102-level-15-state-1-line-2-incorrect-syntax-near of MediumTex ... 05 Oct: 2 minor suggestions 05 Oct: Multiple "From IP"s in user manager 05 Oct: Remember queries between sessions (?RFC) DonateHow to donate List of donors HelpRequirements Connecting to a server Command line switches The database tree Creating a table Creating a view Creating a stored procedure Creating a trigger Creating a scheduled event The Data tab Running SQL queries SQL export http://www.heidisql.com/forum.php?t=19454 HeidiSQL portable License Credits SQL Error (102): Incorrect syntax near ''. New topic Register Log in 16 posts Suncatcher posted 1 year ago in General I get this error while trying to execute simplest select via F9 [url=http://s11.postimg.org/jyk12rddv/Unbenannt2.png[/url] But I swear that syntax is absolutely correct. In SSMS 2012 it works like a charm. Also it works in Heidi if I select the code explicitly and press Ctrl-F9. Any suggestions? 16 posts Suncatcher posted 1 year ago http://s11.postimg.org/jyk12rddv/Unbenannt2.png 13 posts Ghastlie posted 1 year ago Does it work if you remove the [ and ]'s? 13 posts Ghastlie posted 1 year ago Does it work if you remove the [ and ]'s? Sorry, scrap that. Derp moment. 16 posts Suncatcher posted 1 year ago Does it work if you remove the [ and ]'s? No, the same result. But at least it started to highlight keywords. 1 posts Ajit posted 12 months ago Can you post SQL query here? 16 posts Suncatcher posted 12 months ago Can you post SQL query here? Extremely simple query! /****** Script for SelectTopNRows command from SSMS ******/ SELECT TOP 1000 [cmCostCenter] ,[cmLogonName] 360 games PC games https://support.microsoft.com/en-us/kb/935563 Windows games Windows phone games Entertainment All Entertainment Movies & TV Music Business & Education Business Students & educators http://www.codeproject.com/Questions/606683/SqlplusScriptpluserrorplusinplusSQLplus-plusMsg Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet sql server Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Lumia All incorrect syntax near Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ Sql Script error in SQL 2008 Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '.'. Rate this: Please Sign up or sign in to vote. See more: SQL-Server SQL-Server-2008 , + Hi there. I get the following error on my SQL manager when I want to run a script. Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '.'. Below is the Script. use eqcas SELECT cat_validation.name, cat_validation.description, cas_user_ext.email cat_validation.primarypin FROM eqcas.dbo.cas_user_ext cas_user_ext, eqcas.dbo.cat_validation cat_validation WHERE cat_validation.id = cas_user_ext.x_id AND ((cat_validation.expiration Is Null)) Go What could be the problem? Posted 13-Jun-13 23:18pm John Wayne52256 Add a Solution Comments Adhikari Surendra 14-Jun-13 5:20am can you show your table structure?? John Wayne52 14-Jun-