Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1103199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:18:22+00:00 2026-05-17T01:18:22+00:00

String myQuery1 = insert into mytable(mycol) values(myval) \ngo; String myQuery2 = insert into mytable(mycol)

  • 0
String myQuery1  = "insert into mytable(mycol) values(myval) \ngo";
String myQuery2  = "insert into mytable(mycol) values(myval2) \ngo";
String myQuery = myQuery1 + myQuery2;

Query query = myEntityManager.createNativeQuery(myQuery);
List<?> insertResultList = queryInsertDefaults.getResultList();

using the eclpise debugger I can see the string used, it works fine when I copy and paste into sql server management studio – so I am guessing there is something to do with entity manger that doesn’t like multiple line statements/go … ?

Any advice gratefully recieved (yeah I know about stringbuilder etc etc), and the error I get is :

 SQL Error: 102, SQLState: S0001
 Incorrect syntax near 'go'.

EDIT
turns out insert is not supported by entitymanager and query class. So I have to use either a prepared statement or persist the object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:18:22+00:00Added an answer on May 17, 2026 at 1:18 am

    From the MSSQL documentation: “GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.”

    That’s why it works in SSMS but not when sent ‘directly’ to the database. Just remove it from your INSERT statements completely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with PreparedStatement with MySQL Server. example: String myQuery = "select id from
String query = select email from emp_select; Statement stmt; try { DB db=new DB();
string abc = This is a string; How do I load abc into a
I have hibernate query as below: String mySql = SELECT S.col1, S.col2, T.col3, T.col4,
I'm trying to find the best way to format an sql query string. When
I need to create a Linq query that would have the following logic: IEnumerable<string>
String query = SELECT * FROM mydatabase.Adminitrators; Statement st = con.createStatement(); ResultSet rs =
i am trying to run the following statement in excel: Dim myquery As String
string a = sea; string b = SEA if (a == b)... How could
String baseString=POST&; String subBaseString = oauth_consumer_key=+oauth_consumer_key+&oauth_nonce=+nonce+&oauth_signature_method=+oauth_signature_method; subBaseString += &oauth_timestamp=+ oauth_timestamp+&oauth_token=+oauth_token+&oauth_version=1.0; baseString += URLEncoder.encode(baseRequest, UTF-8);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.