Hello @Shalabh Gupta ,
The BDC Identity column resides in the SharePoint External List, not in SQL DB. Thus, its data is NOT transferred to SQL DB like the data in all the other fields.
You could try to the below script:
using Microsoft.SharePoint;
using System;
using System.Web;
class whatif
{
static void Main()
{
String siteUrl = "http://wn10101/StatusBook";
using (SPSite site = new SPSite(siteUrl))
{
site.AllowUnsafeUpdates = true;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPServiceContextScope scope = new Microsoft.SharePoint.SPServiceContextScope(SPServiceContext.GetContext(site)))
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Manage Spread Steps"];
// query items
SPQuery query = new SPQuery();
query.Query =
@"<Where>
<IsNull>
<FieldRef Name='BDCIdentityKey' />
</IsNull>
</Where>
<OrderBy>
<FieldRef Name='Group'/>
</OrderBy>";
query.ViewFields =
@"<ViewFields>
<FieldRef Name='SpreadKey'/>
<FieldRef Name='Topic'/>
<FieldRef Name='Group'/>
<FieldRef Name='BdcIdentity'/>
<FieldRef Name='BDCIdentityKey'/>
</ViewFields>";
// RowLimit has no effect
query.RowLimit = 1;
SPListItemCollection items = list.GetItems(query);
foreach (SPListItem item in items)
{
item["BDCIdentityKey"] = item["BdcIdentity"].ToString();
// Set all fields.
item.Update();
Console.WriteLine("SpreadKey: '{0}', Group: '{1}', BdcIdentity: {2}, BDCIdentityKey: {3}",
item["SpreadKey"],
item["Group"],
item["BdcIdentity"],
item["BDCIdentityKey"]);
}
Console.Write("Press Enter to continue!");
Console.ReadLine();
}
});
}
}
}
Here is a similar case for your reference:
Thanks,
Echo Du
==================
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.