Why?
Hmm... I was writing a stored procedure that will scramble data given a table as a parameter. Because I only want to update a temporary table and not the original (source) table, I needed the following stored procedure (or part of).
What?
This will copy a given table into a temporary table all the while maintaining the structure and data.
Thinking inside of the box
I think everyone suggests the following (or at least the idea of):
copyrawstyler
SELECT *
INTO #MyTempTable
FROM @GivenTable
- SELECT *
- INTO
- FROM @GivenTable
If
@GivenTable is a parameter then the above will simply return an error. Also, if it was this easy, I wouldn't need to post this note on my website.
Category: Transact-SQL :: Article: 424