I have a very simple INSERT statement being executed from a PHP script running on a Linux Apache web server. I can run the query fine from within SQL Management Studio and
You can use the code in the message to know which is the error. For example:
[2627: The statement has been terminated.]
In this case, the error code is 2627, so if you execute the sql below you'll know the message
SELECT msg.text
FROM sys.messages msg
INNER JOIN sys.syslanguages lng ON lng.msglangid = msg.language_id
WHERE msg.message_id = 2627
AND lng.alias = 'English'
Violation of %ls constraint '%.*ls'. Cannot insert duplicate key in object '%.*ls'. The duplicate key value is %ls.
This is a way to know the right message error. In my example the error is violation of primary key