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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:05:23+00:00 2026-06-13T15:05:23+00:00

I have multiple table names like g_str_a , g_str_ab , g_str_abc . I would

  • 0

I have multiple table names like g_str_a , g_str_ab , g_str_abc . I would like to drop all those tables that start with g_str on SQL Server 2008.

Will DROP Tables like 'g_str' help?

Please help me with the script.

  • 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-13T15:05:24+00:00Added an answer on June 13, 2026 at 3:05 pm

    Following query will delete tables automatically:

        BEGIN TRANSACTION
    
        DECLARE @tmpTablesToDelete TABLE ( 
                                            RowNumber INT PRIMARY KEY
                                           ,Query NVARCHAR(MAX)
                                         )
    
        INSERT INTO
                @tmpTablesToDelete 
        SELECT 
             RowNumber = ROW_NUMBER() OVER (ORDER BY (SELECT (0)))
            ,'DROP TABLE '+schemas.name+'.'+objects.name AS Query
        FROM 
            sys.objects 
        INNER JOIN
            sys.schemas
        ON
            schemas.schema_id = objects.schema_id
        WHERE 
            type = 'U' AND objects.name like 'g_str%'
    
        DECLARE @Counter INT
        SELECT @Counter = MAX(RowNumber) FROM @tmpTablesToDelete
    
        WHILE(@Counter > 0) BEGIN
    
            DECLARE @Query NVARCHAR(MAX)
    
            SELECT @Query = Query FROM @tmpTablesToDelete WHERE RowNumber = @Counter
    
            PRINT @Query
    
            EXEC sp_executesql @statement = @Query
    
            SET @Counter = @Counter - 1
    
        END
    
        COMMIT TRANSACTION
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple buttons that gets created in a table which all look like
I have a table that contains members names and a field with multiple ID
all. I would like to ask if it is possible to have multiple forms
I have multiple tables that need to be merged into one. SELECT name, SUM(money)
I have 3 tables event, location, event_location. Event can have multiple locations. Location table
I have a mysql table that looks something like this: id | col_1 |
I have two tables. One table looks like ORDER_ID | SHOPPER_NAME | DATE -------------------------------
I have instances of Item that I would like to have in groups ItemGroup
I have multiple columns in a mySQL table. Three of the columns are named
I have a table a which have multiple entry of artikelNr for it to

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.