troubleshooting Question

TRUNCATE and INSERT INTO SQL table DYNAMICALLY based on columns in SQL table.

Avatar of Queennie L
Queennie L asked on
Microsoft SQL ServerSQL
14 Comments1 Solution97 ViewsLast Modified:
Hello Experts,

I have a SQL table. See attached copy.

I have multiple companies in companyname column with each corresponding Select statements from each dbo. files table. Each company have exactly the same column fields. I want to insert each company "SelectFromTable" column into table in "InsertIntoTable" column dynamically. But before inserting into table, I want to delete the table first dynamically.

This is what I want to accomplish with the query:

Select "TrucateTable" , "InsertIntoTable" from dbo.DynamicTable

Can this be possible?

Thank you again for all your help.
TRUNCATEandINSERTtableDYNAMICALLY.xlsx
ASKER CERTIFIED SOLUTION
D B
Database Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros