SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how to create dynamic excel sheets and load data in ssis


how to create dynamic excel sheets and load data in ssis

Author
Message
asrinu13
asrinu13
SSC Veteran
SSC Veteran (206 reputation)SSC Veteran (206 reputation)SSC Veteran (206 reputation)SSC Veteran (206 reputation)SSC Veteran (206 reputation)SSC Veteran (206 reputation)SSC Veteran (206 reputation)SSC Veteran (206 reputation)

Group: General Forum Members
Points: 206 Visits: 543
Hi I have one doubt in ssis, how to create dynaimic excel sheets based daily running using below conditions : conditions: if current date(systemdate) dayname is monday then i want load previouse year data(currentyear-1) and should be

create dynamic monthandyear sheetname and corresponding data: example: suppose today is monday then my packge should be load only pervious year data in the excel file and excel file should be contain monthandyearsheetsofpreviousdata. here:excelfilename is :2017 and sheetsname:jan2017..>this should contain only jan2017 related data,2nd sheet for feb2017: this file only feb2017 related data only, for march2017 sheet:its should contain only march2017 data similary upto dec2017 sheets create dynamicaly.

if current date(systemdate) dayname is tuesday then want create dynamic sheet for previous month data of current year:

example: supuose today is tuesday then i want load data only previous month of currentyear data into the excel sheet:that means we need load only january2018 data only in excel file.

if current date(systemdate) dayname is Wednesday then want create dynamic sheet for previous last 3 months data from current date: example:upuose today is Wednesday then i want create excel sheets dynamicaly only for last 3 months of current data sheets : Jan2018,dec2017,nov2017 sheets with corresponding data.

if current date(systemdate) dayname is Thursday then want create dynamic sheet for previous year of may month data only : example:upuose today isThursday then i want create excel sheets dynamicaly only for may month data sheet: may2017 sheets with corresponding data.

if current date(systemdate) dayname is Friday then want create dynamic sheet for previous year related August and september and December months data : example:upuose today is Friday then i want create excel sheets dynamica only for previous 3 required months data sheets: Aug2017,sep2017,Dec2017 sheets with correspondin data.

if current date(systemdate) dayname is Saturday then want create dynamic sheet for previous year related August month data : example:upuose today is Friday then i want create excel sheets dynamica only for previous August required months data sheets: Aug2017 correspondin data. please tell me how to achive this task in ssis:

souce table: emp

CREATE TABLE [dbo].[emp](
[country] [varchar](50) NULL,
[empname] [varchar](50) NULL,
[doj] [date] NULL
) ON [PRIMARY]
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'hari', CAST(N'2017-10-12' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'BANU', CAST(N'2017-11-12' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'JAI', CAST(N'2017-09-15' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'JAIA', CAST(N'2017-09-19' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'CHEN', N'H', CAST(N'2017-08-06' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'AUS', N'YN', CAST(N'2017-07-04' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'SA', N'TN', CAST(N'2017-06-02' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'UN', CAST(N'2017-05-22' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'F', CAST(N'2017-04-02' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'AUS', N'TN', CAST(N'2017-02-28' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'YN', CAST(N'2017-03-03' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'CHEN', N'YE', CAST(N'2017-12-25' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'CHEN', N'UI', CAST(N'2017-12-29' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'YE', CAST(N'2018-01-12' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'TB', CAST(N'2018-02-07' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'CHEN', N'RE', CAST(N'2018-01-19' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'TE', CAST(N'2017-01-29' AS Date))
I trield like below
enter image description here


using foreachadoenutrator task.but its not working.can you please tell me how to achieve this task in ssis.
tim.ffitch 25252
tim.ffitch 25252
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1124 Visits: 187
asrinu13 - Wednesday, February 7, 2018 4:56 AM
Hi I have one doubt in ssis, how to create dynaimic excel sheets based daily running using below conditions : conditions: if current date(systemdate) dayname is monday then i want load previouse year data(currentyear-1) and should be

create dynamic monthandyear sheetname and corresponding data: example: suppose today is monday then my packge should be load only pervious year data in the excel file and excel file should be contain monthandyearsheetsofpreviousdata. here:excelfilename is :2017 and sheetsname:jan2017..>this should contain only jan2017 related data,2nd sheet for feb2017: this file only feb2017 related data only, for march2017 sheet:its should contain only march2017 data similary upto dec2017 sheets create dynamicaly.

if current date(systemdate) dayname is tuesday then want create dynamic sheet for previous month data of current year:

example: supuose today is tuesday then i want load data only previous month of currentyear data into the excel sheet:that means we need load only january2018 data only in excel file.

if current date(systemdate) dayname is Wednesday then want create dynamic sheet for previous last 3 months data from current date: example:upuose today is Wednesday then i want create excel sheets dynamicaly only for last 3 months of current data sheets : Jan2018,dec2017,nov2017 sheets with corresponding data.

if current date(systemdate) dayname is Thursday then want create dynamic sheet for previous year of may month data only : example:upuose today isThursday then i want create excel sheets dynamicaly only for may month data sheet: may2017 sheets with corresponding data.

if current date(systemdate) dayname is Friday then want create dynamic sheet for previous year related August and september and December months data : example:upuose today is Friday then i want create excel sheets dynamica only for previous 3 required months data sheets: Aug2017,sep2017,Dec2017 sheets with correspondin data.

if current date(systemdate) dayname is Saturday then want create dynamic sheet for previous year related August month data : example:upuose today is Friday then i want create excel sheets dynamica only for previous August required months data sheets: Aug2017 correspondin data. please tell me how to achive this task in ssis:

souce table: emp

CREATE TABLE [dbo].[emp](
[country] [varchar](50) NULL,
[empname] [varchar](50) NULL,
[doj] [date] NULL
) ON [PRIMARY]
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'hari', CAST(N'2017-10-12' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'BANU', CAST(N'2017-11-12' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'JAI', CAST(N'2017-09-15' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'JAIA', CAST(N'2017-09-19' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'CHEN', N'H', CAST(N'2017-08-06' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'AUS', N'YN', CAST(N'2017-07-04' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'SA', N'TN', CAST(N'2017-06-02' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'UN', CAST(N'2017-05-22' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'F', CAST(N'2017-04-02' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'AUS', N'TN', CAST(N'2017-02-28' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'YN', CAST(N'2017-03-03' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'CHEN', N'YE', CAST(N'2017-12-25' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'CHEN', N'UI', CAST(N'2017-12-29' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'INDIA', N'YE', CAST(N'2018-01-12' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'TB', CAST(N'2018-02-07' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'CHEN', N'RE', CAST(N'2018-01-19' AS Date))
GO
INSERT [dbo].[emp] ([country], [empname], [doj]) VALUES (N'USA', N'TE', CAST(N'2017-01-29' AS Date))
I trield like below
enter image description here


using foreachadoenutrator task.but its not working.can you please tell me how to achieve this task in ssis.

The design pattern for Excel is to have a template spreadsheet file that you copy and then write your data into the spreadsheet.At design time the Excel connection manager points to the template but you need to change the file path at run time to the new file you just created.

A word of warning about the 2003 onward file format (xlsx) and ACE drivers. If you require a heading row and data formats in the spreadsheet are important then you need to add a dummy row after your heading row. Find a column in the template that will contain text and either fill it with spaces or add something like "Dummy Row". When data is written to the spreadsheet without a blank row the data formatting will be applied the same as the heading row, create a gap and the format set is according to the data being written in. Once the data is written in you can run an Execute SQL task to UPDATE the column to a Zero Length String WHERE the value = "Dummy Row". You will be left with a blank row between your heading and data but it is a small price to pay for correctly formatted data.

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search