Does anyone know how to use this setting in SQL 2019?
ALTER DATABASE SCOPED CONFIGURATION
SET VERBOSE_TRUNCATION_WARNINGS = ON
I ran that and it says it ran but when I test it by creating a table and inserting data longer than it is set to accept, I still don't get verbose messages. same useless error that the data would be truncated.
Asking most obvious question first: Did you set this on all of the databases you're working with? If you're using temp tables, then probably want to run it on tempdb too, just in case it got turned off.
USE myDatabase; -- do this for each DB you want to generate the new message
ALTER DATABASE SCOPED CONFIGURATION
SET VERBOSE_TRUNCATION_WARNINGS = ON;
For database compatibility level 140 or lower, error message 2628 remains an opt-in error message that requires trace flag 460 to be enabled, and this database scoped configuration has no effect.
I usually select the db I'm running it on in the dropdown first when creating a new query. but i did run the user db command just to be sure. but still no change to the syntax.
yikes! never heard of this and it sounds very confusing to me. You able to provide an example of what this might look like using my example? Like how would I input this using my query?
then wrap your query in TRY block and in CATCH block insert the ERROR_MESSAGE() in the table. There are other error information available.
BEGIN TRY
INSERT INTO dbo.CoolPeople(PersonName, PrimaryCar)
VALUES ('Baby', '2007 Subaru Impreza WRX GD');
END TRY
BEGIN CATCH
INSERT INTO dbo.TruncateError (message)
VALUES (ERROR_MESSAGE())
END CATCH;