T-SQL Script to Generate Select Query for Tables in List

Job ID: 34678309

Budget: $10 – $30 USD

T-SQL to generate select query for tables in a list TABLE_LIST. We have a list of 50 tables to insert. The first column is identity. The script will be able to generate the select statements for all tables in a list TABLE_LIST. The insert statement will need to have the table name in the from statement and the IDNUM in the where statement. Exclude the identity column from the Select Statements. One line per insert statement.


TABLE_LIST
TABLE_NAME, IDNUM
table1, 11112
table2, 11113
.
.
.
table50, 11160

Examples Insert Statements to generate
SELECT IDNUM,c1,c2,c3, c3,c5,c6,c7 FROM table1 WHERE IDNUM = 11112
SELECT IDNUM,c1,c2,c3, c3,c5 FROM table2 WHERE IDNUM = 11113
SELECT IDNUM,c1,c2,c3, c3,c5 FROM table50 WHERE IDNUM = 11160

table1
columns
i1 identity
IDNUM
c1
c2
c3
c3
c5
c6
c7

table2
columns
i1 identity
IDNUM
c1
c2
c3
c3
c5

Query Results
Select * from table 1

i1,IDNUM,c1,c2,c3, c3,c5,c6,c7 (Table Columns)
1,11111, 1, 2, 3, 4, 5, a, b
2,11111, 1, 2, 3, 4, 1, f, b
3,11111, 1, 2, 4, 4, 5, a, f
4,11112, 4, 5, 6, 7, 6, c, d
5,11112, 4, 5, 6, 7, 6, c, e


Select * from table 2

IDNUM,c1,c2,c3, c3,c5 (Table Columns)
1,11111, 1, 2, 3, e, f
2,11111, 1, 1, 3, e, g
3,11112, 4, 5, 6, g, f
4,11112, 4, 5, 3, g, j


Confidentiality.
a) No Use. Recipient agrees not to use the Confidential Information in any way, or to manufacture or test any product embodying Confidential Information, except for the purpose set forth above.
b) No Disclosure. Recipient agrees to use its best efforts to prevent and protect the Confidential Information, or any part thereof, from disclosure to any person other than Recipient's employees having a need for disclosure in connection with Recipient's authorized use of the Confidential Information.
c) Protection of Secrecy. Recipient agrees to take all steps reasonably necessary to protect the secrecy of the Confidential Information, and to prevent the Confidential Information from falling into the public domain or into the possession of unauthorized persons.
d) Scope. The scope of Confidentiality is deemed to be in all contracts present past and future with the Parties to this request