During Development today, I encountered the problem of counting the number of database tables in SQL Server 2005. So I wrote the SQL statement myself: Select count (1) From sysobjects where xtype = 'u'. Once executed, I found that the number of
There are two statements:
Select @ versiongo
Selectserverproperty ('productversion') as productversion, serverproperty ('productlevel') as productlevel, serverproperty ('version') as edition, serverproperty ('engineedition ') as engineedition;
Case may be one of the keywords most misused in SQL. Although this keyword may have been used before to create a field, it also has more features. For example, you can use case in the WHERE clause.
First, let's take a look at the case syntax. In a
-- Return value using parameterdirection. returnvalue;Create procedure DBO.AsDeclare @ I intSelect @ I = count (*) from tbd_m_modleReturn @ IGo
-- Return value using parameterdirection. output;Create procedure DBO.@ I int outputAs
Select @ I = count
-- It can be used for real tables.If exists (select * From sysobjects where id = object_id (n' [DBO]. [Table name] ') and objectproperty (ID, n'isusertable') = 1)Drop table [DBO]. [Table name]
-- It can be used for temporary tables (Note: if you use
If object_id ('tb') is not nullDrop table TBGoCreate Table Tb (name varchar (25 ))Insert into TBSelect 'z, Y, W, C' Union allSelect '1, 2, 3, 4'
Select name = substring (A. Name, B. Number, (charindex (',', A. Name + ',', B. Number)-B. Number)From
Creating an index on a view requires three conditions:1. The view must be bound to the architecture.To do this, you must add with schemabinding to the create view statement. If you are using the Enterprise Manager, right-click the blank area in the
Recently, a friend of mine told me that the execution of many stored procedures in his database has timed out. let me show him why. I saw that many temporary tables and variable tables were used in his stored procedures. so I told him that I was too
/* -- Paging program implemented by stored procedures
Displays page X of the specified table, view, and query result.
In the case of primary keys or ID columns in the table, query the data directly from the original table. In other cases, use the
Two paging SQL statements
The first one is the. Not in
Select Top 2 * From xy_role where id not in (select Top 4 ID from xy_role)
'2' indicates the number of information entries displayed on each page. '4': for example, if the current page
Because SQL server does not calculate the number of weeks and the number of weeks based on the Start Week (Monday is the first day of a week or Sunday, share with you.
I. Calculate the number of weeks based on the Start week: fn_getweekday
Create
Project requirements: In my stored procedures, you need to call the stored procedures written by others in the group and obtain the dataset returned by the Stored Procedure for joint query with my own data.
This stored procedure includes input and
1: returnvalue can only return data such as 0, 1,-1, with great limitations. In the stored procedure, the output parameter can return various types of data, which is flexible and convenient.
Returnvalue is used to return the error code, and output
During project development, we should be familiar with database transactions, but how can we use transactions well?
I would like to share some of the following notes with you:
1. For the business to be processed, the transaction operation time
For the database system that has just been installed, if it is installed by default, it is likely that an error is reported during remote connection. The common error is: "When you connect to SQL Server 2005, this failure may occur if SQL server
Let's look at the example. Suppose there is only one users table with two fields: ID and PWD.
1. The simplest usage:
select * from users for xml auto
The result is as follows:
2. The method for generating a node for each data row (Note: The default
--> Title: SQL Server execution plan--> Author: wufeng4552--> Date: 15:08:24
Preface:
Recently, I have written some of my understanding about online planning. I have made the following arrangement to help students better understand their impressions
Ranking function detailsSQL Server2005 is able to rank data rows in T-SQL code. The ranking function can rank each data row, providing a way to organize output in ascending order. You can give each row a unique sequence number, or give each group of
The phenomenon is as follows: The inttype field is an integer.Select * from test where varchartype = 'test' and inttype =''Records with inttype 0 can be found.Update Test Set dcr_times = ''. The value of test is 0.
Differences between Oracle and
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