dotnet / dotnet/dotnet-api-docs
DestinationTableName cannot be a synonym
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
It is worth adding that the destination table cannot be a synonym (as demonstrated by the code below). (It seems weird that this should be the case)
Sql:
drop table if exists myschema.SimpleTable
drop schema if exists myschema;
go
create schema myschema;
go
create table myschema.SimpleTable(Id int);
go
drop synonym if exists dbo.SimpleTable;
go
create synonym dbo.SimpleTable for myschema.SimpleTable;
go
C#:
var tblData = new DataTable();
tblData.Columns.Add("Id", typeof(int));
for (var i = 0; i < 100; i++) tblData.Rows.Add(i);
using (var sqlBulkCopy = new SqlBulkCopy(connectionString) {DestinationTableName = "SimpleTable"})
sqlBulkCopy.WriteToServer(tblData);
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 3d74ea27-ced0-04cf-d0cf-ef8657e5b7e7
* Version Independent ID: 218cca08-9c97-9a81-27c2-e4ae737ec118
* Content: [SqlBulkCopy.DestinationTableName Property (System.Data.SqlClient)](https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlbulkcopy.destinationtablename?view=netframework-4.7.2)
* Content Source: [xml/System.Data.SqlClient/SqlBulkCopy.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Data.SqlClient/SqlBulkCopy.xml)
* Product: **dotnet-api**
* GitHub Login: @douglaslMS
* Microsoft Alias: **douglasl**
Contributor guide
Assessment
This issue has not been assessed yet.