Here is the solution. It is little tricky. Make the query dynamic, so that Syabse wont complain about the syntax error while compile. You compilation will be fine and you will get your desire result in run-time.
create procedure getTitle @title_id VARCHAR(9)
as
declare @error int,
@title varchar(100)
begin
declare @my_query varchar(500)
select @my_query = "insert into tab1 (CODE) VALUES (1) jhghjghj"
exec (@my_query )
SELECT @title = description from master..sysmessages where error = @@error
update ex_employee set info = @title
commit
print "%1!", @title
end
go