Hi, I have some dynamic sql statement which bombs under certain conditions, so I am trying to debug it. it gets built like so:
declare @sql varchar(4000);
...
select @sql = '<part1>';
...
select @sql = @sql + '<part2>';
...
select @sql = @sql + '<part3>';
...
begin
execute(@sql);
select @ec__errno = @@error
if @ec__errno != 0
begin
if @@trancount != 0
begin
rollback;
end
return @ec__errno;
end;
...
As I said, it bombs in a particular iteration of a loop (don't ask me why it is implemented like this, I am just fixing a bug) and I am having a hard time displaying the contents of the string in a watch window. I think I am getting the first 255 characters only. Watching for substring(@sql, 0, 200)
results in 'substring(@sql,0,200)' could not be evaluated
. Please help. I was hoping to watch substrings from 0 to 199, from 200 to 399 and so on, and then piece this thing together and finally debug it.
I would appreciate pointers from you. Thanks!