Having no experience with SQL, I was hoping someone would help me with this.
I have an empty temp table, as well as a table with information in it.
My plan for my request, as it is, is as follows:
CREATE TABLE [#Temp] (ID Int, Field1 Varchar) INSERT INTO [#Temp] SELECT ID, Field1 FROM [Other_table] WHERE ID IN (ID1, ID2, ID3...)
So, I pass the request to a number of identifiers, and where the identifier corresponds to the identifier in Other_table , it should fill the temp table with this information.
Is it possible to store identifiers that do not match somewhere else (for example, another temporary table) in one query? Or in the same temporary table, only with field 1 = NULL in this case?
I need to do extra work on identifiers that have not been mapped, so I need some kind of access to them. I was hoping to do all this in this single request if this is the fastest way.
Edit:
Thanks for the help.
Sorry, now I see that my question is not entirely clear.
If Other_table contains identifiers 1 - 1000, and I pass identifiers 999, 1000 and 1001, I want the temporary table to contain information for 999 and 1000, and then also the record with identifier = 1001 with field 1 = NULL. I do not want identifiers 1 through 998 to be returned with Field1 = NULL.
sql sql-server select insert-into
Alex
source share