Home > Backend Development > PHP Tutorial > How to get the database name of the current sql_PHP tutorial

How to get the database name of the current sql_PHP tutorial

WBOY
Release: 2016-07-13 17:01:06
Original
972 people have browsed it

Here are a few questions about SQL SERVER that I would like to ask you (server-side script programming):
(1) How to obtain the current database name using SQL statements in SQL SERVER?
(2) How to define a global variable instead of a local variable, because I defined a loop here
, in which fields are added to a temporary table and data is inserted into the temporary table
operate. But these two operations must be placed in different batches (need to be separated with a GO statement).
The variable parameters controlling the loop will not work at this time, because the variable parameters can only work in one
batch and will be redefined in the next batch. What a headache! Can I define
a global variable so that it works in all batches?
These two problems are not actually universal, but the ideas and methods to solve these two problems are universal, so I will specifically talk about these two problems
( 1) First of all, it is very certain that the current DataBase needs to use system stored procedures. I naturally thought that after sp_who is executed, all the information of all current system processes is listed. When I see that there is Runnable and Slepping, I am sure. It should be runnable. After looking at its spid, I remembered that there is a system global variable @@SPID. Try it first, sp_who @@spid. Haha, it worked. The solution to this problem is to be familiar with the system's stored procedures and System global variables, and be good at observing and thinking
(2) As for the second question, it is purely a t-sql programming idea. First of all, I don’t agree with using one rule to judge two stored procedures, because This does not comply with the specifications of t-SQL programming, but since the problem has arisen, we must find a way to solve it. We know that it is impossible to share data in the two batches, so I thought of the cursor. After testing, it worked. It worked.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631186.htmlTechArticleHere are a few questions about SQL SERVER that I would like to ask you (server-side script programming): (1) How Use SQL statement to obtain the current database name in SQL SERVER? (2) How to define a...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template