Excel In to a New Table and Export Out to a New Excel File (T-SQL)





 --Load excel file to a new table
 --Convert float data type  to int

 SELECT Expire,Account,Class,Barcode,[First Name],[Last Name]

 into mybarcode


 FROM OPENDATASOURCE(
 'Microsoft.ACE.OLEDB.12.0',
 'Data Source=c:\temp\KS_Membershipstatus.xlsx;Extended Properties=Excel 12.0')...[Sheet1$]  



 -- Export query data to a new excel file  (need to add header columns)

 INSERT INTO OPENDATASOURCE (
 --SELECT * FROM OPENDATASOURCE(
 'Microsoft.ACE.OLEDB.12.0',
 'Data Source=c:\temp\Book1.xlsx;Extended Properties=Excel 12.0')...[Sheet1$]  (Expire,Account,Class,[First Name],	[Last Name], barcode) 

 Select Expire, Account,Class,[First Name],[Last Name], [dbo].[CodeTo128IFBF](Account) as barcode  from mybarcode



 
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s