Using SSIS and finding missing Fields/Columns of an Excel file while importing to SQL Server


i have ssis package looping through excel sheets (tabs) , exporting sql2005, working but....
--- times file missing field or file has empty sheet etl fails
questions
1- how can find sheet/tab (technically table) in excel missing field/column? yes have list of fields/column in variable how can list of fields of excel file compare with.
 
2- how can bypass empty sheets , go next sheet without package failing, remember process done in loop

thanks

http://msdn.microsoft.com/en-us/library/kcax58fh.aspx

imports system  imports system.data  imports system.data.oledb  imports system.text  imports microsoft.sqlserver.dts.runtime    <system.addin.addin("scriptmain", version:="1.0", publisher:="", description:="")> _  <system.clscompliantattribute(false)> _  partial public class scriptmain  	inherits microsoft.sqlserver.dts.tasks.scripttask.vstartscriptobjectmodelbase    	enum scriptresults  		success = microsoft.sqlserver.dts.runtime.dtsexecresult.success  		failure = microsoft.sqlserver.dts.runtime.dtsexecresult.failure  	end enum  	    	public sub main()            dim outputlist new stringbuilder            dim xlconnectionstring string = dts.connections("testcolumnsconnection").connectionstring          dim xlconnection new oledbconnection(xlconnectionstring)          xlconnection.open()            dim tablesinfile datatable = xlconnection.getschema("tables")          dim tablecount integer = tablesinfile.rows.count            ' todo: remove named ranges list of tables.            dim currenttable string          dim columnsintable datatable          dim columnrestrictions(3) string          dim columnintable datarow          dim currentcolumn string            each tableinfile datarow in tablesinfile.rows                currenttable = tableinfile("table_name")              outputlist.append(currenttable & controlchars.crlf)                columnrestrictions(2) = currenttable              columnsintable = xlconnection.getschema("columns", columnrestrictions)                each columnintable in columnsintable.rows                  currentcolumn = columnintable("column_name")                  outputlist.append(" " & currentcolumn & controlchars.crlf)              next            next            xlconnection.close()            system.windows.forms.messagebox.show(outputlist.tostring(), _              "column list", messageboxbuttons.ok, messageboxicon.information)            dts.taskresult = scriptresults.success    	end sub    end class


SQL Server  >  SQL Server Integration Services



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........