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 7848013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:03:52+00:00 2026-06-02T18:03:52+00:00

I am trying to create a script that creates and populates tables, and then

  • 0

I am trying to create a script that creates and populates tables, and then create the stored procedures for my app to access them. My script runs just fine until I get to the stored procedures. I’m trying to read a .sql file into my app and then run this script through my connection in one execution. Is there any way I can remove the ‘go’ keyword from this chunk of the script to make it run in one execution?

if object_id('GetStudentByID') is not null
drop procedure GetStudentByID;
go
create procedure GetStudentByID
(@StudentID INT)
as
select StudentID,FirstName,LastName
from Student
where StudentID = @StudentID;
  • 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-02T18:03:52+00:00Added an answer on June 2, 2026 at 6:03 pm

    Like This:

    if object_id('GetStudentByID') is not null
        EXEC('drop procedure GetStudentByID;');
    
    EXEC('create procedure GetStudentByID
    (@StudentID INT)
    as
    select StudentID,FirstName,LastName
    from Student
    where StudentID = @StudentID;');
    

    This is a common problem because, although it’s not immediately apparent, “GO” is not a SQL Server command. Rather it is a command implemented by Management Studio (and SQLCMD as well), to allow you to tell it how to divide up a stream of SQL command text into separate compilable batches.

    As SQL Server itself has no such command, you have to go about it differently in cases where you need a SQL Script to fit within a stored procedure, Agent Job, etc. The SOP way to do this is via dyanmic SQL using either sp_executeCmd(…) or EXEC(‘string’) (as above).

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

Sidebar

Related Questions

Im trying to create a script that will post a notification stored in a
I am trying to run a large script that creates a table, and then
Just as the title says, I'm trying to create a script that will take
I'm trying to create a simple ajax load test script that dynamically creates divs,
I am trying to create a script that finds the closest store/location to a
im trying to create a script that opens a file and replace every 'hola'
I'm trying to create a script that takes a .txt file with multiple lines
I'm trying to create a Python script that would : Look into the folder
I'm trying to create a shell script that shall convert certain Files according to
I've been trying to create a script for myself that will allow me to

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.