Showing posts with label transfer. Show all posts
Showing posts with label transfer. Show all posts

Wednesday, March 28, 2012

Iterate through all Excel files and all their sheets

hello,

i need to transfer (migrate ) the data from xl sheet to sqlserver but actually the thing is if the source excel file has different sheets, in each sheet i have the data

and i need to move the entire data( all the data that is present in all sheets of the excel file) to a single table into sql server

like wise i have many xl files ( which have many sheets ) .

for eg:

excel file 1:

-> sheet 1

-> sheet 2

-> sheet 3

excel file 2:

-> sheet 1

-> sheet 2

-> sheet 3

excel file 3:

-> sheet 1

-> sheet 2

-> sheet 3

now i need to get the data from all of the files and i need to insert into a single table ( sql server) in ssis package

so plz help me by giving the solution asap.

thanks

B L Rao

hello ,

while i am trying to transfer the data from xl file to table in sql server by using ssis package it is giving error saying that primary key violation and cant insert duplicate value.

i understood that there is some duplicate data but can i find where that duplicate data exists i mean in which row ? because it contains thousands of records.

thanks and regards

B L Rao.

|||You may accomplish this by using 2 nested Loops: One fairly simple, a foreach loop to iterate through all excel files; a second one to iterate through each excel sheet. I am not sure how to implement the second one; perhaps if the number and name of the sheets is always the same you could built a list of values in a variable and then have the excel component to get the table name from a variable. Just an Idea, you would need to figure out the details.

Wednesday, March 21, 2012

Issues with SMO Transfer

I am trying to come up with a way to copy a database from one server to another. I have been running tests using the Transfer method from SMO. I can make it work in some cases and not in others. Currently I am trying to copy a database and am getting an error in a script to create a View. This View is the first one in the list of views from the source database. The problem appears to be that this View refers to another view that has yet to be created in the new database. Is there a way to handle this kind of dependency or is this a limitation to the Transfer method.I'm having the same issue. ScriptTransfer() doesn't seem to generate the scripts in the correct order. Have you been able to resolve it? If so how?|||Have you tried parsing the DependencyTree and scripting the objects based on that order?|||

I was hoping to avoid having to do that. The odd thing about this issue is when we create our database from scripts generated from DB Ghost and then attempt the transfer everything works fine. It's once certain types of changes to that database are made that this problem happens.

Is there an example out there that scripts the entire database using the DependencyTree?

|||

Dim srv As Server
Dim srvConn As ServerConnection
srv = New Server("MyServer")
srvConn = srv.ConnectionContext
srvConn.LoginSecure = True

Dim db As Database
db = srv.Databases("SourceDB")
Dim strDBName As String

strDBName = "DestDB"

Dim xfr As Transfer
xfr = New Transfer(db)
xfr.CopyAllObjects = True
xfr.CopyAllUsers = True
xfr.CopyData = True
xfr.Options.WithDependencies = True
xfr.Options.ContinueScriptingOnError = True
xfr.DestinationDatabase = strDBName
xfr.DestinationServer = srv.Name
xfr.DestinationLoginSecure = True
xfr.TransferData()

|||

Thanks for the response, but that is essentially the code that I'm using when I run into trouble. Except I'm using the ScriptTransfer() function. But, both methods get the same error.

To try and break it down a little further, I executed the scripts in the StringCollection individually:

strColl = xsfr.ScriptTransfer()

Dim i As Integer

For i = 0 To strColl.Count - 1

dbEngagement.ExecuteNonQuery(strColl(i))

Next

I get an exception complaining about a view that doesn't exist while trying to create another view that is dependent upon it. So for some reason the Transfer object is getting the scripts out of order.

Further information:

I just went into Server Manager to check dependencies on the view in question. Server Manager didn't get the dependencies correct either. It left out the the sub-query when checking objects that this object depends on.

Wednesday, March 7, 2012

Issue while using Transfer Sql Server Objects tasks

Hi
I am trying to use Transfer SQL Server Object task to transfer various
DB objects from a Source DB to a newly created Destination DB. The
Destination DB is blank before this attempted transfer.
Now our source Db contains various SPs and views which internally
reference other SPs/Views of the same DB (source DB). For example we
have 2 SPs - SP1 and SP2. Now SP1 internally executes SP2. Whie using
transfer objects task, if we try to transfer all SPs only, we get an
error saying that SP2 does not exist while creating SP1. It seems SSIS
compiles objects while transfering them. We tried to set the
DelayValidation property of the entire package as well as the task to
True, but this didnt help either.
It would be great if someone could suggest some mechanism to prevent
compilation of objects, or any other method using which we can avoid
the problem that we are facing.
Thanks
Regards,
Piyush
I would redirect any failure to a logging table or other, or even ignore
errors.
On 1st pass sp1 will fail, but sp2 should still be created, correct? Then
perform a second pass which will cause sp2 to fail because already exists,
however sp1 will compile and create fine since dependency now exists...
You will get a quicker response if you post to dts group for ssis questions.
good luck.
ChrisB MCDBA
MSSQLConsulting.com
"whirlwnd" wrote:

> Hi
> I am trying to use Transfer SQL Server Object task to transfer various
> DB objects from a Source DB to a newly created Destination DB. The
> Destination DB is blank before this attempted transfer.
> Now our source Db contains various SPs and views which internally
> reference other SPs/Views of the same DB (source DB). For example we
> have 2 SPs - SP1 and SP2. Now SP1 internally executes SP2. Whie using
> transfer objects task, if we try to transfer all SPs only, we get an
> error saying that SP2 does not exist while creating SP1. It seems SSIS
> compiles objects while transfering them. We tried to set the
> DelayValidation property of the entire package as well as the task to
> True, but this didnt help either.
> It would be great if someone could suggest some mechanism to prevent
> compilation of objects, or any other method using which we can avoid
> the problem that we are facing.
> Thanks
> Regards,
> Piyush
>