Ms Sql Server Error Msg 170 Incorrect Syntax Near
(Русский)ישראל (עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsTroubleshootingCommunityForums Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Msg 170, Level 15, State 1, Line 1 SQL Server > SQL Server Security Question 0 Sign in to vote Not sure what went wrong, we are using sql server 2000 version. I m getting the error message, when i m executing the below command: Command: DECLARE @SQLState NVARCHAR(200) SET @SQLState = 'EXEC dbo.sp_MSForEachDB ''USE [?]; IF db_id() NOT IN (1,2,4) revoke connect from guest''' EXEC (@SQLState) Error Message: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'connect'. Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'connect'. Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'connect'. Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'connect'. Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'connect'. Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near 'connect'. Your help is highly appreciated. Thanks, Satish KumarThanks, Satish Kumar. Please mark as this post as answered if my anser helps you to resolves your issue :) Thursday, June 21, 2012 2:33 PM Reply | Quote Answers 0 Sign in to vote The guest user exists in all databasees by default. However, by default the guest user does not have access to the database, unless you explicitly grant it. The exception is master and tempdb where the guest is always enabled, and you cannot revoke access for guest from these two databases. If you look in sysusers, and check the column hasdbaccess, this column should be 0 for guest. Thus, you can be assured that after running your script, you have disabled guest in all databases. Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Marked as answer by S
SQL Server experts to answer whatever question you can come up with. Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums. SQL Server Forums Profile | ActiveTopics | Members | Search | ForumFAQ Register Now and get your question answered! Username: Password: Save Password Forgot your Password? All Forums SQL Server 2000 Forums Transact-SQL (2000) syntax near '(' Reply to Topic Printer Friendly Author Topic sqldummi Starting Member India 4 Posts Posted-09/13/2011: 13:44:53 I keep https://social.msdn.microsoft.com/Forums/sqlserver/en-US/768795b5-accf-4758-9e6a-54fa7b9be439/msg-170-level-15-state-1-line-1?forum=sqlsecurity getting following errors Server: Msg 170, Level 15, State 1, Line 16Line 16: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 12Line 12: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 48Line 48: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 23Line 23: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 16Line 16: Incorrect http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=165357 syntax near '('.Server: Msg 170, Level 15, State 1, Line 9Line 9: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 15Line 15: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 12Line 12: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 28Line 28: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 26Line 26: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 48Line 48: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 16Line 16: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 19Line 19: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 11Line 11: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 21Line 21: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 18Line 18: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 18Line 18: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 11Below is the sql SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOIF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SatT]') AND type in (N'U'))BEGINCREATE TABLE [dbo].[SatT]( [TorID] [varchar](50) NOT NULL, [St
near 'max'. + Ask a Question Need help? Post your question and get tips & solutions from a community of 418,595 https://bytes.com/topic/sql-server/answers/911038-getting-error-msg-170-level-15-state-1-line-18-incorrect-syntax-near-max IT Pros & Developers. It's quick & easy. Getting error :- Msg https://bytes.com/topic/sql-server/answers/560771-isql-msg-170-level-15-state-1-line-1-line-1-incorrect-syntax-near 170, Level 15, State 1, Line 18: Incorrect syntax near 'MAX'. P: 4 Omendra Hi, I am using SQL Server 2005 and i am using Stored Procedure something like :- I am getting error:- Msg 170, Level 15, State 1, Line 18: Incorrect syntax near 'MAX'. DECLARE @jid AS VARCHAR(20), ms sql @DBName As VARCHAR(50), @Query AS VARCHAR(MAX) SET @DBName = 'test' SET @Query = ' DECLARE @jid AS VARCHAR(20), @StartDate AS VARCHAR(50), @endDate AS VARCHAR(50), @DBName As NVARCHAR(50), @PEditorId AS NVARCHAR(2000), @IsDateAssigned BIT SELECT @jid = '+ @PJID + ', @startdate = ' +@Pstartdate+' , @enddate = '+@Penddate +' DECLARE @reviewercount TABLE( cont INT, ms_id INT, rev_no INT) INSERT INTO @reviewercount SELECT Count(*), ms_id, ms sql server ms_rev_no FROM ' + @DBName+'.reviewer WHERE j_id = @jid GROUP BY ms_id, ms_rev_no DECLARE @editorIds TABLE( ed_id INT) DECLARE @String VARCHAR(10) WHILE Len('+ @PEditorId +') > 0 BEGIN SET @String = Left(' + @PEditorId +', Isnull(Nullif(Charindex('','', ' + @PEditorId +') - 1, -1), Len('+ @PEditorId +'))) SET @PEditorId = Substring('+ @PEditorId +', Isnull(Nullif(Charindex('','', '+ @PEditorId +'), 0), Len('+@PEditorId+')) + 1, Len('+@PEditorId+')) INSERT INTO @editorIds ([ed_id]) VALUES ( Cast(@String AS INT) ) END I am getting error:- Msg 170, Level 15, State 1, Line 18: Incorrect syntax near 'MAX'. Mar 31 '11 #1 Post Reply Share this Question 1 Reply 100+ P: 152 gpl what does the generated SQL look like ? try replacing your exec @Query with a Print @Query Do you really need dynamic sql for this? a stored procedure would be much more efficient and would give a better clue as to where your problem is. Mar 31 '11 #2 reply Message Cancel Changes Post your reply Join Now >> Sign in to post your reply or Sign up for a free account. Similar topics why incorrect syntax near ',' when inserting mu
' ' + Ask a Question Need help? Post your question and get tips & solutions from a community of 418,595 IT Pros & Developers. It's quick & easy. ISQL: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax near ' ' P: n/a axtens G'day everyone That's a space between the ticks. It's all part of a longer script but seeing as the failure occurs on line 1 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[config]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[config] GO That's three lines only. Does it matter that they're in Unicode? Any ideas? Kind regards, Bruce M. Axtens Software Engineer Strapper Technologies Nov 8 '06 #1 Post Reply Share this Question 3 Replies P: n/a m.bohse Bruce, are you sure this is the part which causes an error ? It works fine on my system. ou must realise that the line number is always relative to the batch. After GO a new batch starts and any error in the first line of an statement after GO would return an error for line 1. Markus Nov 8 '06 #2 P: n/a m.bohse One more thing I almost overlooked. The error message clearly says Incorrect syntax near ' ' but the code lines you posted don't contain any empty string ' ', so the error must be somewhere else. Markus Nov 8 '06 #3 P: n/a axtens Gentlemen, Thank you for your replies. With ISQL resetting its line number every "GO" the offending line could have been anywhere in a 123 line file. What I ended up doing was creating two scripts from the original: one to do the "DROP"s and the other to do the "CREATE"s. Both ran without a hiccup. Thanks for your time. Kind regards, Bruce M. Axtens Software Engineer Strapper Technologies Nov 9 '06 #4 This discussion thread is closed Start new discussion Replies have been disabled for this discussion. Similar topics Msg 170, Level 15, State 1 Incorrect syntax near '-'.Must declare the scalar variable "@UserName Msg 102, Level 15, State 1, Line 3 in Sql 2005 Line 1: Incorrect sy