Happy Mardi Gras!
I’ve got a few ideas for posts that take more time than the 5 minutes I can spare each day. However today’s a quick one as I’m snowed under with work and the joys of house hunting. I came across this in an old stored proc:
</p><p>select top 0 * into Sales.SalesPersons from sales.SalesPerson<br />
and after a bit of Googling I found out it’s a way of creating a duplicate of the columns in the table. What it does not do is include indexes, constraints and keys. So when is it useful? Well the stored proc it is used in creates a table and switches a partition into the table then drops it. This is to speed up deletes (yes there are checks from dropping multiple runs inside one partition, I am disregarding this for this post). I guess it takes the pragmatic approach that the data would not be in there if there were any constraint violations, we’re not querying this table so indexes are not required and keys are not required for reference or uniqueness.