i tasked pulling information sap , cross referencing information pulled active directory. first step need accomplish figure out how pull information out of sql server. here have far (thanks several users here have answered similar questions):
$sqlserver = "web-prdsq" $sqldbname = "prd" $sqlquery = "select * prd.zemployee;" $sqlconnection = new-object system.data.sqlclient.sqlconnection $sqlconnection.connectionstring = "server = $sqlserver; database = $sqldbname; user id = deleted; password = deleted;" $sqlcmd = new-object system.data.sqlclient.sqlcommand $sqlcmd.commandtext = $sqlquery $sqlcmd.connection = $sqlconnection $sqladapter = new-object system.data.sqlclient.sqldataadapter $sqladapter.selectcommand = $sqlcmd $dataset = new-object system.data.dataset $sqladapter.fill($dataset) $dataset.tables[0] | out-file "c:\scripts\sql\sqldata.csv" and output gives me: http://i.imgur.com/r6y5hu2.png
for one, ugly layout hard read when there 145,361 lines of text. , 2, don't need information. need samaccountname (i don't see 1 of output, that's it's called in ad), emp_id, status, hire_date, location, emp_title, lastlogondate (once again, don't see output know it's in ad), , lastly term_date.
when try change "select * prd.zemployee" , change out * status, hire_date, etc, gives error "invalid column name 'status'" (or whatever column have listed first).
is there out there patient enough work me through , me create this? i've taken 1 database class kinda know talking about, don't know intricate details may require. willing provide information need to.
per earlier conversation...
database collation case sensitive , column names must match same case shown in results file select * from... query.
example: select emp_id, status prd.zemployee
Comments
Post a Comment