View SQL Code Behind Flat File Import Wizard?
The &quot;Import Flat File to SQL Wizard&quot; is actually just an abbreviated version of the more complex &quot;Import &amp; Export Wizard.&quot; It uses the exact same mechanism, but streamlines the process by skipping unnecessary options &amp; picking appropriate defaults for you. Ultimately, the import process uses the same mechanism though.
One of the &quot;hidden&quot; options that is only available in the Import &amp; Export Wizard, is to generate an SSIS Package, rather than executing immediately. The import actually happens via SSIS as a mechanism, rather than pure T-SQL or PowerShell code. Because it is not executing T-SQL or PowerShell directly, it can only output the thing it generates &amp; runs behind the scenes--an SSIS Package.
To access the Import &amp; Export Wizard, right-click on a database, and select `Tasks--&gt;Import Data...&quot; (this is right below &quot;Import Flat File...&quot; on the context menu). Here, you can choose a flat file source, and SQL Server destination.
On the last page of the Import &amp; Export Wizard, you can select to Save as an SSIS Package, or run immediately. If you save as an SSIS package, you will be able to see exactly what SQL Server is doing.