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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:36:09+00:00 2026-05-23T12:36:09+00:00

I have 3000+ tables in my SQL 2008 database with names like listed below,

  • 0

I have 3000+ tables in my SQL 2008 database with names like listed below, that all starts with tempBinary_, that I need to delete programmatically, how do I do that?
I don’t know if I prefer the solution in a SQL-script or with use of LINQtoSQL, i guess both are fine.

tempBinary_002c90322f4e492795a0b8a14e2f7c99
tempBinary_0039f7db05a9456f96eb3cd6a788225a
tempBinary_0057da9ef0d84017b3d0bbcbfb934fb2

I’ve used Like before on columns, but I don’t know if it good for table names too.
Maybe something like this, where LIKE is used, can do it? I don’t know.

Use [dbo].[database_name]
DROP TABLE table_name
WHERE table_name LIKE 'tempBinary_%'

Any ideas?

  • 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-23T12:36:09+00:00Added an answer on May 23, 2026 at 12:36 pm
    declare @stmt varchar(max) = ''
    declare @tbl_name varchar(255)
    
    
    DECLARE tbl_cursor CURSOR  FORWARD_ONLY READ_ONLY
        FOR select name 
            from sysobjects 
            where xtype='u' and name like 'tempBinary%'
    OPEN tbl_cursor
    FETCH NEXT FROM tbl_cursor
    INTO @tbl_name;
    
    WHILE @@FETCH_STATUS = 0
    BEGIN
        set @stmt = @stmt + 'drop table ' + @tbl_name + ';' +  CHAR(13)
    
    
        FETCH NEXT FROM tbl_cursor 
        INTO @tbl_name
    end
    CLOSE tbl_cursor;
    DEALLOCATE tbl_cursor;    
    
    execute sp_sqlexec @stmt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 database tables that looks like this Subscriptions table member_id active 5
I have two tables and need to search for all entries that exist in
I have an SQL document formatted as so (It has about 3000 entries like
I have a db in sql 2008 with 40 tables: On each table there
http://mydomain.com/ => 127.0.0.1:4567 but http://mydomain.com/FOO => 127.0.0.1:3000 Is that possible? So far I have:
I currently have 2000 records in a postgresql database being updated every minute that
I have 2 tables and a view. In product_oper I have some products that
SQL Server 2008 Hi I have an issue where i have two of the
I have 2 tables TABLE A INV AMT DISC 1001 1500 150 1002 3000
I have an XML field in SQL table like this <Root> <Name>Apollo</Name> <Code>1000</Code> <Code>2000</Code>

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.