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

  • SEARCH
  • Home
  • 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 8867501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:03:02+00:00 2026-06-14T17:03:02+00:00

The truth: I am not good at SQL, and after some research I am

  • 0

The truth: I am not good at SQL, and after some research I am unable to figure this out. I am reading a chapter on utilizing views and am unable to get this query to work :

USE [jm0235242]
CREATE VIEW InvoiceBasic 
AS
SELECT VendorName, InvoiceNumber, InvoiceTotal
FROM Vendors JOIN Invoices ON Vendors.VendorID = Invoices.VendorID

It has issues with my USE statement:

‘CREATE VIEW’ must be the first statement in a query batch”.

My question is, how am I supposed to specify which database it is supposed to look at if I cannot use my USE statement. Thanks for any help, and happy thanksgiving!

  • 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-06-14T17:03:04+00:00Added an answer on June 14, 2026 at 5:03 pm

    You need to make sure that the CREATE VIEW is the first statement in a SQL batch – as the error clearly explains. So use this:

    USE [jm0235242]
    GO      --  put that "GO" separator here! 
    
    CREATE VIEW InvoiceBasic 
    AS
    SELECT VendorName, InvoiceNumber, InvoiceTotal
    FROM Vendors JOIN Invoices ON Vendors.VendorID = Invoices.VendorID
    

    When you run this in SQL Server Management Studio, the GO keyword ends a batch and executes it – and the CREATE VIEW is now the first statement in the second batch, and it’s happy and works, too

    Update: the question why exactly the CREATE VIEW (and also ALTER VIEW, for that matter) must be the first statement of a batch eludes me – I’ve never heard any compelling explanation for this. Maybe a Microsoftie or someone close to the team knows this and can explain for us all? 🙂

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

Sidebar

Related Questions

I'm not very fluent in C++, to tell the truth. I have some binary
I could not find an XNOR operator to provide this truth table: a b
I try to run this simplest unit test: test the truth do assert true
I just read this article: The Truth About Garbage Collection In section A.3.3 Invisible
The truth ... I feel a little stand with this problem foo(function(err, a){ foo.buu(function(err,
Okay, this is probably very simple but, I have the below checks (not at
I was reading a good book on JavaScript. It started with: Boolean type take
I know this sounds like something I can google, but the truth is that
Here is my scenario: This problem is couched in terms of liars and truth
My ActiveRecord is not telling the truth. See for yourself: > User.posts.class => Array

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.