Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Handy SQL Server Queries

DZone's Guide to

Handy SQL Server Queries

· Database Zone ·
Free Resource

MariaDB TX, proven in production and driven by the community, is a complete database solution for any and every enterprise — a modern database for modern applications.

These two queries are great when you need to apply some bulk actions...

 

Drop all FK's in a database

SELECT 'ALTER TABLE ' + TABLE_SCHEMA + '.' + TABLE_NAME +

' DROP CONSTRAINT ' + CONSTRAINT_NAME

FROM information_schema.table_constraints

WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'


Drop all tables in a database

exec sp_MSforeachtable "DROP TABLE ? PRINT '? dropped' "


Original post at http://www.steveciske.com/post/Handy-SQL-Queries.aspx

MariaDB AX is an open source database for modern analytics: distributed, columnar and easy to use.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}