question

kbuchanan avatar image
kbuchanan asked

When I type the word, "LOG ON" I am getting an Incorrect Syntax message, Msg 156, Level 15, State 1, Line 3, LOG On, Keyword 'On'

Hi, I'm taking a Udemy Course and trying to complete an exercise. I'm getting an Incorrect Syntax message, "Msg 156, Level 15, State 1, Line 3, Incorrect syntax near the keyword 'ON' when I type the command, LOG ON. I am using SQL 2012 Server Management Studio. Please advise and thanks for your assistance. Kelly Buchanan, Orlando, Florida ![alt text][1] [1]: /storage/temp/4613-msg-156-level-15-state-1-line-3.jpg
syntaxcreatesq
3 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I've been staring at this way too long now that I'm getting crossed eyes! I can't see the problem and I even resorted to comparing it against the MSDN Create Database article - https://docs.microsoft.com/en-us/sql/t-sql/statements/create-database-sql-server-transact-sql?view=sql-server-2017 and it looks good to me! Are you executing your SQL Script in one go or are you high-lighting that one block of code and running it? Have you tried the code in another screen and making sure your Master database is selected and then running it? Just a couple of ideas. I bet this is starring me right in the face and I'm missing it!
1 Like 1 ·
I would suggest that there is something higher up in the script that is causing this. Can you highlight the CREATE DATABASE chunk and just run that?
0 Likes 0 ·
If it's not due to other stuff in the script, it could be that the parameters are in the wrong order. try listing them in the order NAME, FILENAME, SIZE, MAXSIZE, FILEGROWTH. Like the documentation shows... https://docs.microsoft.com/en-us/sql/t-sql/statements/create-database-sql-server-transact-sql?view=sql-server-2017#b-creating-a-database-that-specifies-the-data-and-transaction-log-files
0 Likes 0 ·

1 Answer

· Write an Answer
kbuchanan avatar image
kbuchanan answered
Thanks Everyone: I figured it out. A user error. I executed "Create Database Movie" independently, which created the database and properties on the GUI. Then I wrote the script for the data and log file and tried to execute. I got the syntax error because the database was already created when I first executed. Warm Regards, Kelly Buchanan
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.