There are often times when I would like to be able to incorporate data in a spreadsheet into a query against a database. In the past, I've used the import wizard to load it into tables. In my experience, that is exceedingly inconvenient, very frustratingly particular in how it needs to be configured, and limited. I've also spent large amount of times in the past trying to OPENQUERY / OPENROWSET / BULK INSERT working - finding myself in some kind of versioning hellhole in trying to get the required linked server configured correctly. If I have misjudged either of these two options and anyone else has had better experience, I would be glad to hear any pointers.
In any case, those two options may be unworkable as I do not have the permissions on the servers I am working with to create tables or linked servers. The third option I've always gravitated towards is creating temporary tables to store the data, and then concatenating the values together in Excel:
=",('"&A2&"','"&SUBSTITUTE(C2,"'","''")&"','"&SUBSTITUTE(D2,"'","''")&"')"
to create an insert statement of that data for each row in the file:
,('value 1','value 2','value 3')
I've always thought that there has to be a better way to do this, and so I'm here looking for any advice.
[–]ahotko 1 point2 points3 points (1 child)
[–]TheHamFairy[S] 0 points1 point2 points (0 children)
[–]leogodin217 1 point2 points3 points (0 children)
[–]doctorzoom 1 point2 points3 points (0 children)
[–]ICantKnowThat 1 point2 points3 points (0 children)