I need to be able to select into a temporary table (which is really a copy of the base table, not really 'temporary'). The problem I'm running into is that the base table uses GUIDs for the Primary Key, and upon attempting to run a:
I keep getting a The only thing I can come up with is because the table has a GUID for the Primary Key. Has anybody ran into this before, or have any tips on circumventing the issue? Thanks, Calvin EDIT: Table Structure:
Select Statement:
asked 21 Jun '10, 17:26 Calvin Allen |
The problem has been found and will be fixed in 10.0.1.4088. Later versions (11.*, etc.) already contained the fix. The problem did not affect SELECT ... INTO when creating temporary tables, and happened when the source query's SELECT list contained UNIQUEIDENTIFIER columns. answered 22 Jun '10, 13:45 Bruce Hay I need the result table to be persistent. @Calvin: Would it be sufficient to create the table Invalid_CP_Section_Services explicitely (i.e. by CREATE TABLE) and then use "INSERT Invalid_CP_Section_Services SELECT * FROM Invalid_CP_Section_Services" ? @Volker: That is an option I considered, and will go with if there is no alternative. For the record, SELECT ... INTO can be used to create permanent tables starting with version 11. See the conditions in the documentation (mainly that the SELECT list must contain more than one item, or if * is used then the table name must be given as owner.name). Doesn't help you with 10.0.1 though. @Bruce - The statements work as expected in 10.0.1 unless the table has a GUID primary key. 3
Okay, the problem has been found and will be fixed in 10.0.1.4088. Later versions (11.*, etc.) already contained the fix. The problem did not affect SELECT ... INTO when creating temporary tables. The problem happened when the source query contained UNIQUEIDENTIFIER columns, not just as the primary key. My earlier statement about SELECT ... INTO creating permanent tables starting in 11 was wrong; it's supported and documented in 10 as well. Comment Text Removed
Awesome! Thank you! If you revise your answer for that, I'll mark it as accepted so you can get some brownie points! @Calvin: A bounty for a bugfix - that's a fair deal, methinks:) @Calvin: Why don't you modify Bruce's answer for him, and give him the bounty? @Breck - I evidently don't have enough rep to edit answers. @Calvin: And now even less:) - @Breck: FYI: I can't edit someone else's answers, either. More comments hidden
|
Can't you use
answered 23 Jun '10, 10:23 Thomas Dueme... The table does not exist prior to running these statements. The idea is to have it created on the fly by our upgrade script (which is ran by our IT staff on our clients servers), and then persist if someone needs to review the data. |
This sounds like a bug. What exact version and build number are you using?
10.0.1.4036....
I can also give more exact table definitions if anybody wants to see them.
Yes, please show us your table definitions. I've tried to repro the issue and was not able to.
Added..........
Works in V11 with or without the # prefix, but it looks like the # prefix is necessary in V10 if you have any uniqueidentifier columns: SELECT * INTO #Invalid_CP_Section_Services FROM Consumer_Plan_Section_Services WHERE Vendor_ID IS NULL;