SyntaxTerror
Technical User
I'm writing a complicated script requiring a lot of logic, to the point that I can't make all of the calculations in a single statement. I got to the point where I had something like 5 nested subqueries, SQL wasn't liking it, and my coworker said I was overcomplicating it (the logic of the subqueries made sense conceptually, but SQL wouldn't allow what I was doing...)
We ended up dumping some of the results into a temp table. My coworker wrote it and basically just created the table, inserted the same number of null values as I'd have columns (around 10 values), then updated the column with the results of the calculations in a bunch of statements.
Well, I've found that I need to make ANOTHER temp table to dump more information into (or somehow modify the one I have). The table would need a column for Inventory ID, Site ID, and Inventory Quantity. I don't know how to make a table where I don't specify the datatypes and insert a null value as a placeholder for each piece of data.
e.g.
Perhaps I'm misunderstanding and I'm sorry if I haven't provided sufficient information. I'm happy to answer any additional questions. Thank you.
We ended up dumping some of the results into a temp table. My coworker wrote it and basically just created the table, inserted the same number of null values as I'd have columns (around 10 values), then updated the column with the results of the calculations in a bunch of statements.
Well, I've found that I need to make ANOTHER temp table to dump more information into (or somehow modify the one I have). The table would need a column for Inventory ID, Site ID, and Inventory Quantity. I don't know how to make a table where I don't specify the datatypes and insert a null value as a placeholder for each piece of data.
e.g.
Code:
INSERT INTO #temp_counts
SELECT SiteID,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
Perhaps I'm misunderstanding and I'm sorry if I haven't provided sufficient information. I'm happy to answer any additional questions. Thank you.