Created
September 12, 2013 13:22
-
-
Save ichiroku11/6537195 to your computer and use it in GitHub Desktop.
セット演算子を使った select into と insert into select
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if object_id('tempdb..#Test') is not null | |
| drop table #Test; | |
| select * | |
| into #Test | |
| from (values(1), (2)) as Test(Value) | |
| union all | |
| select * | |
| from (values(3), (4)) as Test(Value); | |
| select * | |
| from #Test; | |
| /* | |
| Value | |
| ----------- | |
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| */ | |
| insert into #Test | |
| select * | |
| from (values(5), (6)) as Test(Value) | |
| except | |
| select * | |
| from (values(6), (7)) as Test(Value); | |
| select * | |
| from #Test; | |
| /* | |
| Value | |
| ----------- | |
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment