0

If so, if my varchar contains ; or [ or the keyward "Create" that will get automatically deleted? I don't think that was this simple, what is the mechanism of parameterization to avoid sql injection?

Il Vic
  • 5,576
  • 4
  • 26
  • 37
KMC
  • 19,548
  • 58
  • 164
  • 253

1 Answers1

4

No, it doesn't remove any characters. Rather, it treats those characters as values rather than as code. If you pass in a string with a semicolon or a quote mark or any other meaningful character/keyword then you'll simply end up with a string value that has that semicolon or quote mark or keyword in it.

If you construct the query as a raw string, rather than using a parameterized query, then you need to ensure that the characters are appropriately escaped in order to have the same behavior, and that's a non-trivial task (if you want to support every possibility) which is why parameterized queries exist to handle it for you.

Servy
  • 202,030
  • 26
  • 332
  • 449