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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:08:20+00:00 2026-06-14T12:08:20+00:00

i inherited an ms sql server 2008 server application and upon checking the stored

  • 0

i inherited an ms sql server 2008 server application and upon checking the stored procedures, i noticed that they start with a USE [ELECS] statement, ELECS being the database name.

when i tried to recreate one of the stored procedures, what i got was an error saying that a stored procedure cannot have a use statement.

Msg 154, Level 15, State 1, Procedure TESTME, Line 3 a USE database
statement is not allowed in a procedure, function or trigger.

does ms sql server have a special feature that allows this?

  • 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-14T12:08:21+00:00Added an answer on June 14, 2026 at 12:08 pm

    You most likely saw USE above the CREATE/ALTER PROCEDURE statement.

    In which case it was being used to set which database the procedure should be updated on.

    It cannot be used within a stored procedure, but if you wish to make reference to a different database you can set this in your table reference. Ie: for a SELECT statement:

    SELECT *
    FROM [DatabaseName].dbo.[TableName]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that in T-SQL (Server 2008 R2) I can use the 'Output' keyword
I've inherited a system using SQL Server (2008 R2) with two tables that cover
I have inherited a SQL Server 2008 database to which calling applications have access
I am working on WPF application in C#. Database is SQL Server 2008. I
I am using ASP classic with ADO, connecting to SQL Server 2008. I inherited
I am am trying to construct a database in SQL Server 2008 R2 that
I am trying to create a stored procedure in SQL Server 2008. According to
All SQL Servers are SQL Server 2008.... I have a table that is replicated
I have created CustomerTbl in SQL Server 2008. For that i have, Right Clicking
I have a table that stores stock ticks in sql server 2008. It is

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.