Deleting rows from a table on a linked serverHow can I remove duplicate rows?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?Check if table exists in SQL ServerHow to concatenate text from multiple rows into a single text string in SQL server?LEFT JOIN vs. LEFT OUTER JOIN in SQL ServerInserting multiple rows in a single SQL query?Insert results of a stored procedure into a temporary tableHow do I UPDATE from a SELECT in SQL Server?

Query about absorption line spectra

What (else) happened July 1st 1858 in London?

What major Native American tribes were around Santa Fe during the late 1850s?

Why do IPv6 unique local addresses have to have a /48 prefix?

Can a significant change in incentives void an employment contract?

Is XSS in canonical link possible?

Drawing ramified coverings with tikz

Open a doc from terminal, but not by its name

Do Legal Documents Require Signing In Standard Pen Colors?

Proving a function is onto where f(x)=|x|.

Is it possible to have a strip of cold climate in the middle of a planet?

What is the gram­mat­i­cal term for “‑ed” words like these?

Greco-Roman egalitarianism

Hot bath for aluminium engine block and heads

Journal losing indexing services

Folder comparison

What is this type of notehead called?

Should I stop contributing to retirement accounts?

Are lightweight LN wallets vulnerable to transaction withholding?

How must one send away the mother bird?

Freedom of speech and where it applies

Divine apple island

THT: What is a squared annular “ring”?

Why has "pence" been used in this sentence, not "pences"?



Deleting rows from a table on a linked server


How can I remove duplicate rows?Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?Check if table exists in SQL ServerHow to concatenate text from multiple rows into a single text string in SQL server?LEFT JOIN vs. LEFT OUTER JOIN in SQL ServerInserting multiple rows in a single SQL query?Insert results of a stored procedure into a temporary tableHow do I UPDATE from a SELECT in SQL Server?













0















I have created a linked server named [abc]. this linked server has a table named [Shipment_data] . Following are the columns in [Shipment_data] table: [start_date], [end_date],[route_type]



I want to delete the rows from this table where start_date and end_date is null.



But it looks like the normal delete operation does not work for tables on linked servers:



I tried the following codes, but no luck. Below are my codes and the error messages that i am getting for the same:



method1:



Declare @deleteRow nvarchar(max)
Declare @linkedServerName nvarchar(max)
Set @linkedServerName = 'abc'
Set @DeleteRow = 'Delete from ' + @LinkedServerName + '...Shipment_data where [Start_Date] is null and [End_Date] is null'

Set @sql = 'exec ' + @LinkedServerName + '...sp_executesql ' + (@DeleteRow)

exec (@sql)


error message:




OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc" returned message "Could not delete from specified tables.".
Msg 7320, Level 16, State 2, Line 12
Cannot execute the query "DELETE FROM Shipment_data " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc".




Method2:Direct method



DELETE FROM [abc]...[Shipment_data]
WHERE Start_Date is null and End_date is null


error message:




OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc" returned message "Bookmark is invalid.".
Msg 7346, Level 16, State 2, Line 1
Cannot get the data of the row from the OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc".




Can someone please help me with a way to accomplish this on MS-SQL?










share|improve this question









New contributor




Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • That first statement looks concerning open to Injection.

    – Larnu
    Mar 21 at 13:54











  • You should take a look on openquery docs.microsoft.com/en-us/sql/t-sql/functions/…

    – kcotman
    Mar 21 at 13:55







  • 1





    I assume you are trying to delete rows from either an MS-Access database, or some other Office type database? From my experience this "invalid bookmark" error is related to security. Can you use your linked server to SELECT or UPDATE data? In other words is it only DELETE giving you problems?

    – Richard Hansell
    Mar 21 at 14:04











  • @RichardHansell In my example, the linked server is an excel spreadsheet. I am able to perform Select operation on this linked server. Cannot execute any Update query or Delete query. throws an error saying: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Zev" returned message "Could not delete from specified tables.". Msg 7320, Level 16, State 2, Line 17 Cannot execute the query "DELETE FROM [Shipment_data] " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ABC".

    – Varun Shekhar RC
    2 days ago












  • Is this is a inherent bug in the provider itself? It is not working for any operations(except Select) at all like Update, Delete, Insert into..

    – Varun Shekhar RC
    2 days ago















0















I have created a linked server named [abc]. this linked server has a table named [Shipment_data] . Following are the columns in [Shipment_data] table: [start_date], [end_date],[route_type]



I want to delete the rows from this table where start_date and end_date is null.



But it looks like the normal delete operation does not work for tables on linked servers:



I tried the following codes, but no luck. Below are my codes and the error messages that i am getting for the same:



method1:



Declare @deleteRow nvarchar(max)
Declare @linkedServerName nvarchar(max)
Set @linkedServerName = 'abc'
Set @DeleteRow = 'Delete from ' + @LinkedServerName + '...Shipment_data where [Start_Date] is null and [End_Date] is null'

Set @sql = 'exec ' + @LinkedServerName + '...sp_executesql ' + (@DeleteRow)

exec (@sql)


error message:




OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc" returned message "Could not delete from specified tables.".
Msg 7320, Level 16, State 2, Line 12
Cannot execute the query "DELETE FROM Shipment_data " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc".




Method2:Direct method



DELETE FROM [abc]...[Shipment_data]
WHERE Start_Date is null and End_date is null


error message:




OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc" returned message "Bookmark is invalid.".
Msg 7346, Level 16, State 2, Line 1
Cannot get the data of the row from the OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc".




Can someone please help me with a way to accomplish this on MS-SQL?










share|improve this question









New contributor




Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • That first statement looks concerning open to Injection.

    – Larnu
    Mar 21 at 13:54











  • You should take a look on openquery docs.microsoft.com/en-us/sql/t-sql/functions/…

    – kcotman
    Mar 21 at 13:55







  • 1





    I assume you are trying to delete rows from either an MS-Access database, or some other Office type database? From my experience this "invalid bookmark" error is related to security. Can you use your linked server to SELECT or UPDATE data? In other words is it only DELETE giving you problems?

    – Richard Hansell
    Mar 21 at 14:04











  • @RichardHansell In my example, the linked server is an excel spreadsheet. I am able to perform Select operation on this linked server. Cannot execute any Update query or Delete query. throws an error saying: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Zev" returned message "Could not delete from specified tables.". Msg 7320, Level 16, State 2, Line 17 Cannot execute the query "DELETE FROM [Shipment_data] " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ABC".

    – Varun Shekhar RC
    2 days ago












  • Is this is a inherent bug in the provider itself? It is not working for any operations(except Select) at all like Update, Delete, Insert into..

    – Varun Shekhar RC
    2 days ago













0












0








0








I have created a linked server named [abc]. this linked server has a table named [Shipment_data] . Following are the columns in [Shipment_data] table: [start_date], [end_date],[route_type]



I want to delete the rows from this table where start_date and end_date is null.



But it looks like the normal delete operation does not work for tables on linked servers:



I tried the following codes, but no luck. Below are my codes and the error messages that i am getting for the same:



method1:



Declare @deleteRow nvarchar(max)
Declare @linkedServerName nvarchar(max)
Set @linkedServerName = 'abc'
Set @DeleteRow = 'Delete from ' + @LinkedServerName + '...Shipment_data where [Start_Date] is null and [End_Date] is null'

Set @sql = 'exec ' + @LinkedServerName + '...sp_executesql ' + (@DeleteRow)

exec (@sql)


error message:




OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc" returned message "Could not delete from specified tables.".
Msg 7320, Level 16, State 2, Line 12
Cannot execute the query "DELETE FROM Shipment_data " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc".




Method2:Direct method



DELETE FROM [abc]...[Shipment_data]
WHERE Start_Date is null and End_date is null


error message:




OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc" returned message "Bookmark is invalid.".
Msg 7346, Level 16, State 2, Line 1
Cannot get the data of the row from the OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc".




Can someone please help me with a way to accomplish this on MS-SQL?










share|improve this question









New contributor




Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have created a linked server named [abc]. this linked server has a table named [Shipment_data] . Following are the columns in [Shipment_data] table: [start_date], [end_date],[route_type]



I want to delete the rows from this table where start_date and end_date is null.



But it looks like the normal delete operation does not work for tables on linked servers:



I tried the following codes, but no luck. Below are my codes and the error messages that i am getting for the same:



method1:



Declare @deleteRow nvarchar(max)
Declare @linkedServerName nvarchar(max)
Set @linkedServerName = 'abc'
Set @DeleteRow = 'Delete from ' + @LinkedServerName + '...Shipment_data where [Start_Date] is null and [End_Date] is null'

Set @sql = 'exec ' + @LinkedServerName + '...sp_executesql ' + (@DeleteRow)

exec (@sql)


error message:




OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc" returned message "Could not delete from specified tables.".
Msg 7320, Level 16, State 2, Line 12
Cannot execute the query "DELETE FROM Shipment_data " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc".




Method2:Direct method



DELETE FROM [abc]...[Shipment_data]
WHERE Start_Date is null and End_date is null


error message:




OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc" returned message "Bookmark is invalid.".
Msg 7346, Level 16, State 2, Line 1
Cannot get the data of the row from the OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "abc".




Can someone please help me with a way to accomplish this on MS-SQL?







sql-server tsql






share|improve this question









New contributor




Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Mar 21 at 13:53









Larnu

21.9k51833




21.9k51833






New contributor




Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 21 at 13:49









Varun Shekhar RCVarun Shekhar RC

12




12




New contributor




Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Varun Shekhar RC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • That first statement looks concerning open to Injection.

    – Larnu
    Mar 21 at 13:54











  • You should take a look on openquery docs.microsoft.com/en-us/sql/t-sql/functions/…

    – kcotman
    Mar 21 at 13:55







  • 1





    I assume you are trying to delete rows from either an MS-Access database, or some other Office type database? From my experience this "invalid bookmark" error is related to security. Can you use your linked server to SELECT or UPDATE data? In other words is it only DELETE giving you problems?

    – Richard Hansell
    Mar 21 at 14:04











  • @RichardHansell In my example, the linked server is an excel spreadsheet. I am able to perform Select operation on this linked server. Cannot execute any Update query or Delete query. throws an error saying: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Zev" returned message "Could not delete from specified tables.". Msg 7320, Level 16, State 2, Line 17 Cannot execute the query "DELETE FROM [Shipment_data] " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ABC".

    – Varun Shekhar RC
    2 days ago












  • Is this is a inherent bug in the provider itself? It is not working for any operations(except Select) at all like Update, Delete, Insert into..

    – Varun Shekhar RC
    2 days ago

















  • That first statement looks concerning open to Injection.

    – Larnu
    Mar 21 at 13:54











  • You should take a look on openquery docs.microsoft.com/en-us/sql/t-sql/functions/…

    – kcotman
    Mar 21 at 13:55







  • 1





    I assume you are trying to delete rows from either an MS-Access database, or some other Office type database? From my experience this "invalid bookmark" error is related to security. Can you use your linked server to SELECT or UPDATE data? In other words is it only DELETE giving you problems?

    – Richard Hansell
    Mar 21 at 14:04











  • @RichardHansell In my example, the linked server is an excel spreadsheet. I am able to perform Select operation on this linked server. Cannot execute any Update query or Delete query. throws an error saying: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Zev" returned message "Could not delete from specified tables.". Msg 7320, Level 16, State 2, Line 17 Cannot execute the query "DELETE FROM [Shipment_data] " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ABC".

    – Varun Shekhar RC
    2 days ago












  • Is this is a inherent bug in the provider itself? It is not working for any operations(except Select) at all like Update, Delete, Insert into..

    – Varun Shekhar RC
    2 days ago
















That first statement looks concerning open to Injection.

– Larnu
Mar 21 at 13:54





That first statement looks concerning open to Injection.

– Larnu
Mar 21 at 13:54













You should take a look on openquery docs.microsoft.com/en-us/sql/t-sql/functions/…

– kcotman
Mar 21 at 13:55






You should take a look on openquery docs.microsoft.com/en-us/sql/t-sql/functions/…

– kcotman
Mar 21 at 13:55





1




1





I assume you are trying to delete rows from either an MS-Access database, or some other Office type database? From my experience this "invalid bookmark" error is related to security. Can you use your linked server to SELECT or UPDATE data? In other words is it only DELETE giving you problems?

– Richard Hansell
Mar 21 at 14:04





I assume you are trying to delete rows from either an MS-Access database, or some other Office type database? From my experience this "invalid bookmark" error is related to security. Can you use your linked server to SELECT or UPDATE data? In other words is it only DELETE giving you problems?

– Richard Hansell
Mar 21 at 14:04













@RichardHansell In my example, the linked server is an excel spreadsheet. I am able to perform Select operation on this linked server. Cannot execute any Update query or Delete query. throws an error saying: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Zev" returned message "Could not delete from specified tables.". Msg 7320, Level 16, State 2, Line 17 Cannot execute the query "DELETE FROM [Shipment_data] " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ABC".

– Varun Shekhar RC
2 days ago






@RichardHansell In my example, the linked server is an excel spreadsheet. I am able to perform Select operation on this linked server. Cannot execute any Update query or Delete query. throws an error saying: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Zev" returned message "Could not delete from specified tables.". Msg 7320, Level 16, State 2, Line 17 Cannot execute the query "DELETE FROM [Shipment_data] " against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ABC".

– Varun Shekhar RC
2 days ago














Is this is a inherent bug in the provider itself? It is not working for any operations(except Select) at all like Update, Delete, Insert into..

– Varun Shekhar RC
2 days ago





Is this is a inherent bug in the provider itself? It is not working for any operations(except Select) at all like Update, Delete, Insert into..

– Varun Shekhar RC
2 days ago












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Varun Shekhar RC is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281940%2fdeleting-rows-from-a-table-on-a-linked-server%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Varun Shekhar RC is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Varun Shekhar RC is a new contributor. Be nice, and check out our Code of Conduct.












Varun Shekhar RC is a new contributor. Be nice, and check out our Code of Conduct.











Varun Shekhar RC is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281940%2fdeleting-rows-from-a-table-on-a-linked-server%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript