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 a table in SQL Server 2000 that I am trying to query
I have a MySQL table with approximately 3000 rows per user. One of the
Have you ever seen any of there error messages? -- SQL Server 2000 Could
We have updated our servers with Windows 2008 Server, but we are still using
I have the following table structure in my database: create table Encargado( ID int
I feel like a bit of a newbie posting this, but anyway: I have
I have a table with just 3,000 records. I render these 3000 records in
I have a table with columns like these : idx | amount | usercol1
i have a Dimension Table like this : my_Table pk1 Primary key pk2 Primary
I have a project that adds elements to an AutoCad drawing. I noticed that

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.