-- Call method:
-- Select * From getchild ('24 ')
-- Select ID from getchild ('24 ')
-- Select * From kucun where producttype in (select ID from getchild ('24 '))
Create Function [DBO]. [getchild] (@ ID varchar (10 ))
Returns @ t table (ID varchar (10), parentid varchar (10), Level INT)
As
Begin
Declare @ I int
Set @ I = 1
Insert into @ t select @ ID, @ ID, 0 -- current level, current level. If not, comment out or add another parameter to select an operation.
Insert into @ t select
First, the table structure of a table needs to be copied from one data (a) library to another database (B). The operation step is as follows:① in Database A, select the tables that you want to replicate. Right-Select the Edit table script to creat to the new Query editing window.② in the newly opened Query window, use CTRL + A to copy the script after you select all.③ opens a new query. Paste the copied scr
server| Create | stored Procedure | dynamic | data | database
The following are ways to create databases, tables, stored procedures, views, indexes, rules, modify tables, view data, and so on, using SQL statements. The controls you want to add are as follows:
Imports System.DataImports System.Data.SqlClientPublic Class
SQL UNION operator
The UNION operator is used to merge the result sets of two or more SELECT statements.
Note that the SELECT statement within the UNION must have the same number of columns. The column must also have a similar data type . Also, the order of the columns in each SELECT statement must be the same.
SQL UNION SyntaxSELECT column_name (s) from table_name1UNIONSELECT column_name (s) from table_
Label:This article is reproduced in the address: http://jingyan.baidu.com/article/d5c4b52bc5c102da570dc547.htmlDuplicate table structureIn the process of using SQL Server, we may need to copy the table from one database to another, and today, we will introduce you to the specific methods and steps of this operation.1. First, open and connect to SQL
Label: mentioned above: Article from Baidu Experience Operation: In the process of using SQL Server, we may need to copy the table from one database to another, and today we will introduce the specific methods and steps for this operation.Duplicate table structure
1First, open and connect to SQL Server, right
Recently do data transfer, due to misoperation, in the system table master tables created n multiple tables is really impossible to deleteFind the following ways to share---Specify the tables in the database to be deleted use mastergodeclare @sql varchar (8000), @TableName varchar () BEGIN DECLARE cur cursor for Sele
Question: How can I list all books with prices greather than the average price of books of the same type?In database pubs, have a table named titles, its column named Price mean the price of the book, and another named type mean the type of books.Now I want to get the result as below:
Program Code Type title price--------------------------------------------------------------------------------------------
SQL
Server Temporary tables of are divided into local temporary tables and global temporary tables, which are described as follows in books online:
There are two types of temporary tables: local and global, both of which ha
The pivot and Unpivot relational operators are the new features provided by SQL Server 2005, so when you use pivot and UNPIVOT for databases that are upgraded to SQL Server 2005, the compatibility level of the database must be set to 90 (you can use sp_ Dbcmptlevel stored procedures to set the compatibility level.
Usi
The pivot and Unpivot relational operators are the new features provided by SQL Server 2005, so when you use pivot and UNPIVOT for databases that are upgraded to SQL Server 2005, the compatibility level of the database must be set to 90 (you can use sp_ Dbcmptlevel stored procedures to set the compatibility level.
Usin
Tags: style ext color width int setSQL Servercursors are generally used to traverse tables, andSQL Server can easily loop through cursors to implement SQL Server traversal records in tables. However, cursors are not recommended for actual development. We know that you can al
after the where can be added not
--7 alias as
SelectB.freezetime,b.* fromQ_user asbSelectB.* from(Select * fromQ_user) bSelectUid asNumber, uName name, upwd password fromQ_user--8 Top Query (how many lines before query)
--SQL Available
Select Top Ten * fromQ_userwhereUid not inch(Select Top TenUid fromQ_user)--query not the first 10 data (i.e. 20-30 data) in the first 10
Select * fromQ_user--Aggregation Functions
--avg
Select AVG(uId) asAverage
) + 'id from # Tmp )'?????? Exec Sp_ExecuteSql @ Str, n'@ WokNo Varchar (500) output', @ WokNo OutPut?????? Select @ WokNo, @ I -- display the employee ID in one row?????? Set @ I = @ I + 1??? End
TemporaryTableYesCreateLocal and globalTemporaryTable. LocalTemporaryThe table is only visible in the current session; GlobalTemporaryThe table is visible in all sessions.LocalTemporaryThe table name is preceded by a number character (# table_name), while th
Tags: Combo key tar PNG create use share task today GESIn the process of using SQL Server, we may need to copy the table from one database to another, and today I'll show you how and how to do this. It may be a simple thing for most people, but it is better to record it than to write a good memory. Hope can help the students who need ... Copy table structure: First step: First, open and connect to
How to copy SQL Server tables and EXCEL Data in batches (solved)
1. Copy SQL Server table data to excel (method)
1. Create a New query and read the table data using SQL statements.
2. Then, right-click the data and copy it (you
. valid inputs include: COLUMN, CONSTRAINT, EVENT NOTIFICATION, INDEX, PARAMETER, TRIGGER, and NULL.
[@level2name =] {'
level2_object_name '}
The name of the level 2 object type specified. level2_object_name is sysname, with a default of NULL."> The Level2_object_name data type is sysname and the default value is NULL.
level2_object_name is sysname, with a default of NULL.">Example:
level2_object_nam
Data dictionary is a good thing, for development, maintenance is very important.However, it is not convenient to write descriptive narration in SQL Server, how to simplify and add changes to the extended attributes in batches?It would be nice to add 2 tables and 5 stored procedures, 2 triggers, and a table-valued function.Run the following
: increments of several numbers at a time wildcard characters:_: There is only one character% any of any charactersLike ' (used to modify)Having said so much, we should pay attention to some common problems;01. Foreign Key control is not good02. In SQL Server, string and date type data are enclosed in single quotes, and numeric types are not03. Each table must have a primary key, the table without the prima
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.