Bulk Copy from sqlserver to AZURE

Hi,

I want to insert data in AZURE database via SQLBulkCopy , writetoserver() method.

But getting failed ,it is giving error login failed for User "ABC" ,while login with AZURE database is successful.

connection string:

"Server=tcp:***.database.windows.net,1433;Database=***;User ID=SQLAdmin@***;Password=***;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
Getting Failed here: 
bulkCopy.WriteToServer(SourceData);


Please

March 26th, 2015 11:52am

WriteToServer() working fine (ex: copy data from localDatabase(.sdf) to sqlserverDatabse)

but not with AZURE database

Free Windows Admin Tool Kit Click here and download it now
March 26th, 2015 11:54am

https://social.msdn.microsoft.com/forums/azure/en-US/home?category=windowsazureplatform

You should post to the Szure forum.

March 26th, 2015 9:15pm

Hi,

I want to insert data in AZURE database via SQLBulkCopy , writetoserver() method.

But getting failed ,it is giving error login failed for User "ABC" ,while login with AZURE database is successful.

connection string:

"Server=tcp:***.database.windows.net,1433;Database=***;User ID=SQLAdmin@***;Password=***;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
Getting Failed here: 
bulkCopy.WriteToServer(SourceData);


Please Help..

Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 11:35am

Hi Anurag,

Thanks for posting here.

I suggest you to check this link for details.

https://msdn.microsoft.com/en-us/library/ex21zs8x(v=vs.110).aspx

Hope the example would help you.

Girish Prajwal

March 27th, 2015 2:48pm

Can you provide the specific error message associated with your issue?

Thanks

Free Windows Admin Tool Kit Click here and download it now
March 27th, 2015 4:53pm

Hi Girish,

This line of codes works with sql server not for AZURE Because AZURE not supported temptable.

So Is there any other way to do this ?

Kind Regards

Anurag Prajesh

March 28th, 2015 5:32am

When we click upload button it is giving above error. Help me?

Free Windows Admin Tool Kit Click here and download it now
March 28th, 2015 10:35am

What do you mean by temp table?  I don't see temp tables in the code.  Below is a worked standalone SqlBulkCopy example.  If you still get an error, post the error message.

            var azureConnectionString = "Server=tcp:***.database.windows.net,1433;Database=***;User ID=***;Password=***;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            var dropTableSql = "IF OBJECT_ID(N'dbo.BcpTest') IS NOT NULL DROP TABLE dbo.BcpTest;";
            var createTableSql = "CREATE TABLE dbo.BcpTest(TestColumn nvarchar(20) NOT NULL CONSTRAINT PK_BcpTest PRIMARY KEY);";

            using(var azureConnection = new SqlConnection(azureConnectionString))
            using (var bulkCopy = new SqlBulkCopy(azureConnectionString))
            {

                //create test table
                azureConnection.Open();
                var azureCommand = new SqlCommand(dropTableSql, azureConnection);
                azureCommand.ExecuteNonQuery();
                azureCommand.CommandText = createTableSql;
                azureCommand.ExecuteNonQuery();

                //bulk copy a row into test table
                bulkCopy.DestinationTableName = "dbo.BcpTest";
                var SourceData = new DataTable();
                SourceData.Columns.Add(new DataColumn("TestColumn", typeof(String)));
                var row = SourceData.NewRow();
                SourceData.Rows.Add(row);
                row["TestColumn"] = "Azure BCP test";
                bulkCopy.WriteToServer(SourceData);
                bulkCopy.Close();

                //drop test table
                azureCommand.CommandText = "IF OBJECT_ID(N'dbo.BcpTest') IS NOT NULL DROP TABLE dbo.BcpTest;";
                azureCommand.ExecuteNonQuery();
                azureConnection.Close();

            }

March 28th, 2015 10:36am

Hi Anurag, please see Dan's post here.

Free Windows Admin Tool Kit Click here and download it now
March 28th, 2015 3:42pm

I see you've asked the same question more than once in this forum.  Please don't do that as it causes additional effort by all parties involved.&n

March 28th, 2015 4:24pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics