Home How to check what column in INSERT do not have the correct data type?
Reply: 0

How to check what column in INSERT do not have the correct data type?

user7446
1#
user7446 Published in September 19, 2018, 11:03 am

Imagine I have 200 columns in one INSERT statement, and I occasionally get an "Cannot convert" error for one of columns. Things is, I do not know which column causes this error.

Is there any way in T-SQL or mybatis to check WHICH column has the incorrect format? (I have just date, char, numeric). I can use ISNUMERIC, ISDATE for every column, but this is not so elegant.

I'm using mybatis in Java, so I cannot use any PreparedStatement or so.

share|improve this question
  • 3
    Use parameters & binding so you won't get that error since your variables should be the correct type. Also, isnumeric doesn't even guarantee you won't get the error. – James Z Apr 15 at 11:49
  • I'm using mybatis in Java. – Mejmo Apr 15 at 12:13
  • 1
    IsNumeric() is notoriously problematic. Modern versions of SQL Server have Try_Convert(). – HABO Apr 15 at 13:12

2 Answers 2

active oldest votes
up vote 1 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.465739 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO