Differences between SQL statements in stored procedure execution and in SSMs

Source: Internet
Author: User
Tags management studio

Differences between SQL statements in stored procedure execution and in SSMs

SSMs is Sqlserever Management Studio. The scenario described in this article is tested in SQLServer2008.

Sometimes the same few statements are found, the OK is executed in SSMs, but the error is executed by the stored procedure. The problem basically involves the processing of temporary tables. Practice has found the following differences, programming developers must pay attention to, can be less detours.

1, after executing the stored procedure, the temporary table is no longer present and cannot be accessed. While SSMs executes, the intermediate temporary table can continue to be accessed as long as the current process is not closed (the current window).

2, in the stored procedure through the Exec execution statement, the dynamically generated temporary table, once the exec ends, even if the stored procedure is still executing, the subsequent statements can no longer access the temporary tables that were generated dynamically by the exec execution statement. If you want to continue to access, there are two ways, one is in the same exec procedure call, the second is to create a temporary table, insert the statement in Exec, then after the exec end, the temporary table will still exist to be accessible.

In general, the SSMs execution environment is more relaxed and generally performs normally, while stored procedures often produce errors. Therefore, the statement cannot be debugged only in SSMs, and must be called by the stored procedure to make a final conclusion.

Differences between SQL statements in stored procedure execution and in SSMs

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.