Skip to content

How to use sys.sp_MSForEachTable stored procedure of mssql in order to delete all data #3477

Answered by Julien-R44
guntribam asked this question in Help
Discussion options

You must be logged in to vote

Hey 👋 I don't know Microsoft SQL Server at all, but here it looks like the problem is your question marks. Knex interprets ? and ?? as positional bindings. So you have to escape them like this :

EXEC sys.sp_MSForEachTable 'ALTER TABLE \\? NOCHECK CONSTRAINT ALL'

We can now see that the interogation point is well escaped :
https://runkit.com/embed/zv95i4w0cu5e

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@guntribam
Comment options

Answer selected by guntribam
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants