How to drop database table created by specific user

Satale, Sandip (Pune) 21 Reputation points
2022-05-19T08:57:08.373+00:00

There is need to setup a maintenance job to drop database tables created by particular user list in SQL SERVER.

I was trying to use Sys.Objects, Sys.tables and sysusers objects but not able to build exact TSQL For this.

Please provide solution.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,691 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,552 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Nandan Hegde 29,886 Reputation points MVP
    2022-05-19T09:05:14.923+00:00

    Hey,
    Below query would help you get that list :
    select
    so.name, su.name, so.crdate
    from
    sysobjects so
    join
    sysusers su on so.uid = su.uid

    and then you can use dynamic sql to drop those