Hi All,I need to pass the messages coming from sql server to the asp.net application so I have the following scriptCREATE TABLE tbl_sample( [ID] INT, [NAME] VARCHAR(10),)GO\I am trying to insert values to this tables through a stored procedure below is my stored prcoedureSET ANSI_WARNINGS ONGOalter procedure sp_test( @Id int, @name varchar(10))ASINSERT INTO tbl_sample ([ID],[NAME]) VALUES (@Id,@name)When I try to insert a statemnt in this table that is bigger than the width of the column, the statement just gets inserted without giving any error. below is the statement:sp_test 1, 'Bob Jack Creasey'I want to see the warning/error message saying "String or binary data would be truncated.The statement has been terminated." I want to send that warning/error message back to my application so that the user know that they are inserting the value in the table that is bigger than the width of the column.I also tried setting the SET ANSI_WARNINGS ON;How can I achieve this? Any help will be greatly appreciated.
↧