Annoyance of print Statements in SQL

Source: Internet
Author: User
Tags sql server sql
Statement
A few days ago to write a program, accidentally encountered a strange problem.

Symptoms are described as follows:

The SQL Server service is installed on one of the Lenovo servers, and a stored procedure is written in one of its databases. This stored procedure takes a parameter that is judged by the statement in the argument and then executes the branch.

If @CustType =0

..................

else if @CustType =1

.......................

Else

...............



The basic structure is this.

When I was developing, I used the program on my Laptop (Compaq) to connect to the server and the recordset in the ADO in the program. There is no problem when executing to rs.open. It is also OK to execute the call stored procedure with this program on the server.

But when you use the same program to access the other computers in that unit, when you run to the first situation in the stored procedure, all forms are automatically closed, and no exceptions appear.

There is a special situation, because the problem was previously on one of the Lenovo machines, then I went to see the problem and couldn't find out why. So I installed the VS6 on this computer, on-site debugging, but I debug everything normal, after one months, and then the original problem (form all closed)

That's a big problem. The same program is sometimes normal when it is executed on different computers, and I believe there is absolutely nothing wrong with the program. I think there may be a problem with the computer configuration. So when a computer redo, try again, still can't.

Think about whether the SP did not hit, and will be nearly two hours to install all the SPS. Still not normal. It is no use to install VS6 again. What is the problem? I think carefully, I have thought will be Lenovo's broken machine has a problem, will not be his CPU instructions wrong.  (Because the machine is a bit older, it never happens on other computers). I tried to change the value of the first case in the program, which was 0 and changed to 3. So I changed the IF @CustType =0 in the stored procedure to if @CustType =3. The problem has arisen again. Whether the problem appears in this branch, the logic inside is certainly right. See the last line of code in this branch, which is used when debugging. To view the execution of a stored procedure, the loss of what statement is executed, that is, a print (@SqlStr), will not be caused by this statement. Comment it out. Open the program and try again. Passed on the computer of the knife.

It turns out that this problem is caused by the print statement. Blame it on some clients that do not have a problem when they do not report any exceptions, but automatically close the client form. It seems that you must pay attention to this problem when you write the program later. To clean up the debug code. I spent nearly a day in vain.


Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.