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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:53:54+00:00 2026-05-25T06:53:54+00:00

I have two lines of code in SQL that create two tables on the

  • 0

I have two lines of code in SQL that create two tables on the fly, i need to do something like

IF TABLE EXISTS 
    DROP IT AND CREATE IT AGAIN
ELSE
    CREATE IT

my lines are the following ones

CREATE TABLE ##CLIENTS_KEYWORD(client_id int)     
CREATE TABLE ##TEMP_CLIENTS_KEYWORD(client_id int)   

how can I apply that concept for these two tables in my procedure?

  • 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-25T06:53:54+00:00Added an answer on May 25, 2026 at 6:53 am

    From SQL Server 2016 you can just use

     DROP TABLE IF EXISTS ##CLIENTS_KEYWORD
    

    On previous versions you can use

    IF OBJECT_ID('tempdb..##CLIENTS_KEYWORD', 'U') IS NOT NULL
    /*Then it exists*/
    DROP TABLE ##CLIENTS_KEYWORD
    CREATE TABLE ##CLIENTS_KEYWORD
    (
       client_id INT
    )
    

    You could also consider truncating the table instead rather than dropping and recreating.

    IF OBJECT_ID('tempdb..##CLIENTS_KEYWORD', 'U') IS NOT NULL
      TRUNCATE TABLE ##CLIENTS_KEYWORD
    ELSE
      CREATE TABLE ##CLIENTS_KEYWORD
      (
         client_id INT
      ) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script in T-SQL that goes like this: create table TableName (...)
I have two database tables, users and logs. I need SQL code to do
I have a SQL query that is returning a table like the following: id
I have a script that generates two lines as output each time. I'm really
Suppose I have two documents that are identical except the lines are shuffled. Is
I have two db tables. One table contains Forecast data. The second table contains
I have a simple method that just does two lines and tries to return
I'm trying to simulate some code that I have working with SQL but using
I am trying to create a relation/table in Oracle that is between two many
I have a UILabel with space for two lines of text. Sometimes, when the

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.