When i do select into query, insert fails, but the table is created. why!?

%3CLINGO-SUB%20id%3D%22lingo-sub-1232002%22%20slang%3D%22en-US%22%3EWhen%20i%20do%20select%20into%20query%2C%20insert%20fails%2C%20but%20the%20table%20is%20created.%20why!%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1232002%22%20slang%3D%22en-US%22%3E%3CP%3Ehi%2C%20I'm%20parksuseong.%26nbsp%3B%20I%20am%20using%20sql%20server%202016%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20to%20the%20following%20query.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ESELECT%20CONVERT(BIGINT%2C%20'A')%20col1%20INTO%20%23tmp%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThis%20query%20is%20obviously%20in%20error.%26nbsp%3BBecause%20it%20does%20not%20convert.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EHowever%2C%20the%20temporary%20table(%23tmp)%20is%20created%20even%20if%20the%20query%20fails.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Ewhy!%3F%26nbsp%3B%3C%2FSPAN%3EI%20think%20this%20is%20a%20issue%20designed%2C%20but%20I%20want%20to%20know%20for%20obvious%20reasons.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1232002%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Ei%20do%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

hi, I'm parksuseong.  I am using sql server 2016

 

I tried to the following query. 

SELECT CONVERT(BIGINT, 'A') col1 INTO #tmp

 

This query is obviously in error. Because it does not convert.

However, the temporary table(#tmp) is created even if the query fails.

 

why!? I think this is a issue designed, but I want to know for obvious reasons.

 

thanks

 

 

0 Replies