January 14, 2009 at 4:05 am
Hi All,
I have output wmi data into a .xls spreadsheet successfully using a powershell script. I now want to import that .xls from my local desktop into a remote database table.
I know you can do this this sqlcmd however I'm having trouble getting sqlcmd to work correctly. I've started looking at BCP.exe which seems like a simple alternative.
Does anyone know the BCP command to get a local .xls file loaded into a remote sql table?
I can manage to get the command working if I copy the data out of the .xls and into a .txt:
db = TEST
table = LogMemory
server = lonwintel01
file = import.txt
This bcp command works for .txt file - does anyone know the correct switches for a .xls file:
bcp TEST..LogMemory in "c:\ps\scripts\import.txt" -S lonwintel01 -T -c
Many thanks
January 15, 2009 at 8:02 am
Unfortunately I don't have the answer for you question. But I wanted to offer other possible solutions. First option is to output the wmi to something other than xls and then use bcp to bring in a straight text file that is tab, comma, pipe delimited which is very simple and well documented. Second if you are just outputing the wmi to xls to put it into sql why not just go straight to sql with a wmi call? Bypass this middle step. If you truely need an xls then you can export an xls as well or export it via ssis from sql. Just some thoughts as alternatives since no one else has responded on your issue yet.
January 21, 2009 at 8:54 am
Hi - thanks for the reply.
I've learnt from another user on this website that BCP doesn't work with .xls files so it's a no-goer.
I'd love to do the things you mention however I haven't got a clue how to do them. I was working within my limited knowledge.
Do you know how to pump data straight from powershell into a SQL table then?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply