Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

SQL server gives a syntactical error when running a transact-SQL script


  • Please log in to reply
6 replies to this topic

#1 chromebuster

chromebuster

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:09:37 PM

Posted 30 April 2011 - 03:52 PM

Hi all,
When running a database creation script in Transact-SQL, I get the following error:

"Message 102. Level 15, state 1, line 1
Incorrect syntax near 'semicolon". I understand what this error is telling me, obviously that I have made an error in the Transact-SQL syntax, but the problem is where is it pointing me? I can't figure out what state and level are. This is using SQL Server 2008 R2 Express edition. My script is as follows.



Code:
CREATE DATABASE Mojo1
GO
Create Login Mojo1;
With Password @rank1222;
Use Mojo1;
Create User Mojouser For Login mojo1;
Go

This looks very correct to me, but I must be missing something, for when I execute the script, I always come up with that error. If anyone could tell me where I must have went wrong, I'd appreciate it. Thanks a lot.



Chromebuster

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:37 PM

Posted 30 April 2011 - 04:29 PM

What script are you following to do that? I am pretty familiar with Sql, and I don't recall ever breaking up a statement with semicolons. I don't recall ever seeing a Transact-Sql script doing so either.

#3 chromebuster

chromebuster
  • Topic Starter

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:09:37 PM

Posted 30 April 2011 - 04:34 PM

I'm following this:
http://msdn.microsoft.com/en-us/library/ms173463.aspx

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge


#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:37 PM

Posted 02 May 2011 - 06:23 AM

I'm guessing that since the first line is a statement that tit needs to be terminated with a semicolon.

#5 Didier Stevens

Didier Stevens

  • BC Advisor
  • 2,666 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:03:37 AM

Posted 03 May 2011 - 05:48 AM

Try this (no ; after Mojo1):

CREATE DATABASE Mojo1
GO
Create Login Mojo1
With Password @rank1222;
Use Mojo1;
Create User Mojouser For Login mojo1;
Go

Didier Stevens
http://blog.DidierStevens.com
http://DidierStevensLabs.com

SANS ISC Handler
Microsoft MVP 2011-2016 Consumer Security, Windows Insider MVP 2016-2018
MVP_Horizontal_BlueOnly.png

 

If you send me messages, per Bleeping Computer's Forum policy, I will not engage in a conversation, but try to answer your question in the relevant forum post. If you don't want this, don't send me messages.

 

Stevens' law: "As an online security discussion grows longer, the probability of a reference to BadUSB approaches 1.0"


#6 chromebuster

chromebuster
  • Topic Starter

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:09:37 PM

Posted 03 May 2011 - 11:34 AM

Thanks a lot! Now you seem to know the language very well. Have you worked with it a lot? Because I was just wondering what are some strategies I could use to remember where semicolons go? I would imagine that Microsoft has beginner tutorials on MSDN? Because my goal is to learn to write these scripts considering it can be quicker that way sometimes. My friend doesn't think so, but I think they're great.

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge


#7 Didier Stevens

Didier Stevens

  • BC Advisor
  • 2,666 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:03:37 AM

Posted 04 May 2011 - 01:15 AM

Semicolons terminate statements.

Create Login Mojo1 With Password @rank1222
is one statement, so you can't have a semicolon in the middle of it.

Didier Stevens
http://blog.DidierStevens.com
http://DidierStevensLabs.com

SANS ISC Handler
Microsoft MVP 2011-2016 Consumer Security, Windows Insider MVP 2016-2018
MVP_Horizontal_BlueOnly.png

 

If you send me messages, per Bleeping Computer's Forum policy, I will not engage in a conversation, but try to answer your question in the relevant forum post. If you don't want this, don't send me messages.

 

Stevens' law: "As an online security discussion grows longer, the probability of a reference to BadUSB approaches 1.0"





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users