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

Read why times series is the fastest growing database category.

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

Learn how to get 20x more performance than Elastic by moving to a Time Series database.

Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}