Create a table variable from a table
Very often I need to create a temp table, table variable, or UDTT that is a duplicate or subset of an existing table. I'd like the @table definition to include primary key and unique constraints and any check constraints and default constraints that are in the actual table. No foreign key constraints obviously. SSMS object scripting botches this up by creating a bunch of alter statements instead of including constraints inside the CREATE statement.
7
votes
William Talada
shared this idea