Set Rs=server.createobject ("Adodb.recordset")
On Error Resume Next
Sql= "SELECT * from Your_table"
Rs. Open SQL, Conn
Rsname=rs (0). Name
For i = 1 to RS. Fields.count-1
' RSNAME=RSNAMEAMP;CHR (9) rs (i). Name
rsname=rsname "," rs (i). Name
Next
RSNAME=RSNAMEAMP;CHR (13)
Rs.close
Set rs=nothing
Conn.close
Set conn=nothing
Function E (W)
Dim h
Dim My_array,my_arr
SQL Server String FunctionsString functions are used to perform various operations on characters and binary characters1.ASCII () functionThe ASCII (character_expression) function is used to return the leftmost ASCII code value in a string expression. The parameter character_expression must be a string expression of char or varchar type. Eg:select ASCII (' s '), ASCII ('
SQL Server date function, SQL Server date
Current System Date and Time
Select getdate ()
14:52:27. 123Extract data from date
Day (), month (), year ()
Select getdate ();-14:52:27. 123Select YEAR (getdate ();-2015Select MONTH (getdate ();-6Select day (getdate ();-18
Date Format ConversionCONVERT
Select convert (char (19), getdate (), 120)
Export format: 2
Grammar:
Row_number () over ([
Note:
The ORDER BY clause determines the sequence in which the rows are assigned unique row_number in a particular partition.
Parameters:
return type:
bigint
Examples of limit functional syntax similar to MySQL:
Copy Code code as follows:
SELECT * FROM (select Row_number () over (order by ID ASC) as rownum, * from MyTable) as items WHERE Items.rownum BETWEEN 20 and 30;
SQL Row_number () sort
1
-
- --mod (x, y) x divided by the remainder of Y
- SelectMoD2,3) fromDual--returns 2
A
+ --Power (x, y) x power
the Select Power(2,3) fromDual--returns 8
-
$ --round (X[,y]) x rounding in the Y position
the --y defaults to 0, if Y is negative, 0 is truncated to the right of the decimal point, and if Y is positive, the decimal point is cut to the left.
the Select round(2.2160,2) fromDual--Back to 2.22
the
the --the square root of sqrt (x) x
- Select sqrt(4) fromDual--returns 2
SQL Server table-valued function and scalar-valued function define the way and call difference
SQL stored procedures often need to call some functions to make the process more reasonable, you can also make functions more reusable, but when writing SQL functions you may find
(1) Use of mathematical functions1, the absolute value of ABS () functionSELECT ABS (' 2 ')2. Square root SQRT () functionSELECT SQRT (' 256 ')3. Squared Square () functionSELECT SQUARE (' 6 ')(2) string function1. The ASCII value function that returns the first character of a stringASCII ()SELECT ASCII (' ABCD ')2, string conversion large, lowercase functionsLOWER () Convert string to lowercaseUPPER () Convert string to uppercaseSELECT LOWER (' machi
Solution for slow SQL query caused by custom functions, function SQL
During the report process, one report queries the exchange rate of the corresponding currency, and the exchange rate is in another table, the condition for querying the exchange rate is to query the exchange rate of the previous month of the statistical date in the Exchange Rate Table based on
I saved a tree structure in the department table of the database and looked up all parent departments when the sub-departments are known. the written function is as follows quot; CREATEFUNCTIONqueryAllDept (@ currdeptidvarchar (50 )) returnsvarchar (200) BEGINdeclare @ allnamevarchar (200) DEFAULT #39; #39; declare @ tempnamevarchar (200) DEFAULT #39; #39 ;; declare @ tempparidvar mysqlsql function loo
aggregate function sum indicates how you want to handle the value of the converted column, whether it is the sum (sum), average (avg), Min,max, and so on. For example, if the Week_income table has two data and its week is "Monday", one of the income is 1000 and the other income is 500, then the sum is used here, and the value of the column "Monday" After row to column is of course 1500. After for [week] in ([Monday],[Tuesday] ...) In for [week] means
This function has a none of deterministic, NO SQL, or READS SQL DATA in its declaration and binaryMySQL settings by default are not allowed to create functionsWorkaround 1:Perform:SET GLOBAL log_bin_trust_function_creators = 1;But it doesn't work when it's restarted.Note: The slave must be set at the time of the master copy, or it will cause master-slave synchron
(Str,s) – returns the position of S in str, no then returns 0 SELECT * FROM stud WHERE LENGTH (NAME) >3;SELECT * FROM stud WHERE LENGTH (LTRIM (NAME)) >3; SELECT SUBSTRING (name,1,2) from stud;SELECT * FROM stud WHERE SUBSTRING (name,1,1) = ' King ';//show students surnamed Wang ※ objects between the database and the Java classlistStud class object (Value object, domain object)---table record (one row in the table)Stud attributes (member variables) in a Class object-----table fieldThe next day,
Tags: group_concat find_in_set SQL Server emulation MySQLA value in a field that is separated by a commaFind_in_set (' A ', ' a,b,c,d ') with CHARINDEX (', ' + ' B ' + ', ', ', ' + ' a,b,c ' + ', ') > 0 substitutionIi. examples of group_concat that mimic MySQLselectid, val= (select[value]+ ', ' FROMtbASb whereb.id=a.id forxmlpath (') ) Fromtbas a Groupbyid selectid, [val]=stuff ( (select ', ' +[value] fromtbasb whereb.id=a.id forxmlpath (
Label:I. Connecting queries within a connection Select a. field, B. field from table 1 A, table 2 B where a. field =b. Fields and ... Two. DML Data Manipulation language 1. Add insert INTO values 1-insert into table name values (a list of values corresponding to all field one by one) 2-insert into table name (field list) values (a list that corresponds to the field list one by one) 3-insert into table name select corresponding field list from source table name where condition 4-insert into tabl
value of the Fetch fieldSelect DATEPART (mi,createtime) from Life_unite_product--Take the minute value of the Time fieldSelect DATEPART (ss,createtime) from Life_unite_product--takes the seconds value of the Time fieldSelect DATEPART (ms,createtime) from Life_unite_product--take the millisecond value of the Time fieldSelect DATEADD (yy,-1,createtime) from life_unite_product----fetch Time field (year is reduced by 1)Select DATEADD (mm,3,createtime) from life_unite_product----fetch Time field (mo
SQL median function instance and SQL median instance
Add a table or total_sales
Table:
SQL statement:
Copy codeThe Code is as follows: SELECT * from(SELECT a1.Name, a1.Sales, COUNT (a2.sales) Sales_RankFROM Total_Sales a1, Total_Sales a2WHERE a1.Sales Group by a1.Name, a1.SalesOrder by a1.Sales DESC, a1.Name DESC
This article illustrates the function and usage of SQL Server to implement Split function split string. Share to everyone for your reference, specific as follows:
/*
function Name: F_splittonvarchar function
: To realize the functio
-- SQL 2000 function RecursionAlgorithmIf object_id ('f _ test') is not null drop function f_testGoCreate Function f_test (@ dt int)Returns intAsBeginDeclare @ I intSelect @ I = @ DT + isnull (DBO. f_test (number), 0) from Master .. spt_values where type = 'p' and number = @ dt-1Return @ IEndGoSelect DBO. f_test (10)
Today, I used the attach function of SQL Server 2008 to attach a database. A problem occurred. The error message is:
Unable to open physical file "D: \ Documents ents \ dalt \ XXXX. MDF" Operating System Error 5: "5 (error not found)" (Microsoft SQL Server: Error 5120 )".
I remember that there was no problem with the previous operations. I don't know why, so I ca
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.