THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

Browse by Tags

All Tags » T-SQL » Utility   (RSS)
  • Utility to temporarily drop FOREIGN KEY constraints on a set of tables

    I was working on a database a few weeks back (maybe longer, I am kind of busy with several projects right now), and I wanted to truncate a set of tables. There was one central table, and 8 tables related by a FOREIGN KEY constraint. The central table had 6 million rows, and a few of the other tables 20+ million. TRUNCATE is amazingly fast,and when ...
    Posted to Louis Davidson (Weblog) by drsql on June 15, 2017
  • Utility to script a FOREIGN KEY Constraint

    Note: Amended to include the word include in the first Note (I am a terrible editor of my own writing!) and to fix a bug in the code with a misplaced parenthesis Note: Amended to include cascading and NOT FOR REPLICATION. As noted in my previous post, I am in the middle of building a utility (for work, and for my next SQLBLOG post), that ...
    Posted to Louis Davidson (Weblog) by drsql on May 24, 2017
  • Utility Queries–Structure of Tables with Identity Column

    Edit: At the suggestion of a much knowledgable commenter who shall remain named Aaron, I changed from using schema_name() function to using sys.tables. When writing code that is expected to have reuse, it can be safer to use the tables rather than functions because the tables will work in the context of the database that is in the from ...
    Posted to Louis Davidson (Weblog) by drsql on September 2, 2012
  • Utility Queries–Column Metadata

    Very often, I find myself wanting to query system metadata for columns. Some of the metadata is fairly easy to deal with, like if you want to find column names, just simply querying sys.columns is very straightforward.  But if you want to query data types, it gets stickier.  There are type types listed, one that is the declared type, and ...
    Posted to Louis Davidson (Weblog) by drsql on April 22, 2012
Privacy Statement