Thursday, September 13, 2012 2:53 PM
We can do SELECT * INTO #TmpTbl FROM Tbl.
So I was thinking we can do something similar with OUTPUT, but it doesn't look like you can do that. All the examples I found do it where you first create the temp table or table variable and OUTPUT INTO it.
Am I correct that you can't create temp tables on the fly with OUTPUT INTO?
Thursday, September 13, 2012 3:01 PMModeratorYou're correct. The table must exist before can be used with OUTPUT INTO.
For every expert, there is an equal and opposite expert. - Becker's Law
- Proposed As Answer by Roberson Ferreira _Microsoft Community Contributor Thursday, September 13, 2012 5:05 PM
- Marked As Answer by D00linDalton Thursday, September 13, 2012 5:31 PM
Thursday, September 13, 2012 3:02 PM
What is scenario where you are trying to use the OUTPUT clause?
Can you post a sample query?
BTW, you can create table on-the-fly, by adding an extra SELECT statement with "WHERE 1=2" clause before the query containing OUTPUT clause.
Thursday, September 13, 2012 4:12 PM
OK, thanks Naomi for verifying my initial finding.
And manub, I understand what you are suggesting. I am just trying to avoid manaully creating that table. But like you said, I can run a select * into where 1=2 to create the empty table before I do the sql where I want to use OUTPUT.
Thursday, September 13, 2012 5:10 PM
Check your scenario you can use Merge:
Se esta sugestão for útil, por favor, classifique-a como útil.
Se ela lhe ajudar a resolver o problema, por favor, marque-a como Resposta.