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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:54:27+00:00 2026-06-01T13:54:27+00:00

I have @db_out = ‘aux.dbo.some_table_name’ , and I don’t know how to drop ,

  • 0

I have @db_out = 'aux.dbo.some_table_name' , and I don’t know how to drop , create based on that variable like :

IF OBJECT_ID(@db_out) IS NOT NULL DROP TABLE "@db_out" - not working
CREATE TABLE "@db_out"  .... etc

it creates master.dbo.@dbo_out

How can I use that variable to create that table or verify it and drop it ?

  • 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-01T13:54:28+00:00Added an answer on June 1, 2026 at 1:54 pm

    You will have to build the statement in varchar variable and execute it:

    declare @strSql as varchar(max)
    
    IF OBJECT_ID(@db_out) IS NOT NULL
    BEGIN
       EXEC ('DROP TABLE [' + @db_out + ']')
    END
    set @strSql = 'CREATE TABLE [' + @db_out + '] (' -- Etc
    EXEC (@strSql)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a db query that'll cause a full table scan using a like
I have a little problem that I don't understand. I have a db that
I fear I don't know what I'm doing. 1: I have a table called
What affect does SSL have on the way load balancing works? I know that
We have DB that has massive amount of business logic stored in triggers inside
I have a DB table that contains a comma separated list of ID's (ints)
I have a DB that stores different types of tasks and more items in
We have a DB table that is mapped into a hibernate entity. So far
I have legacy DB that store dates that means no-date as 9999-21-31, The column
I have text in db which looks like this: <p> blah blah blah </p>

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.