Tags: Using data code Time database SQLThese two days to change a SQL Server database program to Oracle, found that two of the functions between the database are many different. The DateDiff function usage in SQL Server's database is explained as follows:DescribeReturns a time interval between two dates.GrammarDateDiff
Label:InstanceMD5 Encryption "123456": Hashbytes (' MD5 ', ' 123456 ') Result: 0xe10adc3949ba59abbe56e057f20f883e (hint: After the end, the result is converted. ) Function
Function
Describe
return value
Hashbytes
Hashbytes (' encryption method ', ' value to encrypt ')Encryption mode = MD2 | MD4 | MD5 | SHA | SHA1
Return value type:varbinary(maximum 8000 bytes)
Hints and Notes123456 of MD5 have tools to know the result: e10adc3949b
Label:Environment: DW is SQLServer2008Modeling tools: Cognos FrameWorkversion:cognos10.2Problem: Create query topic in FM, SQL type data source, introduce macro function #camidlist () # Verify the model directly with the following errorWorkaround, in the #camidlist () # function coat with the SQ function, as shown below#sq (Camidlist ()) # like '%u:cn= ' +user_id+ ' "% 'OK problem solvingThe main purpose is to convert the object before and after the l
It is very inconvenient to process dates in PHP, for example, to find the month of the difference between two dates? What should I do? File name: date. inc. php3 before using these two functions, you must first convert the date or date to the timestamp type. For example: $ todaymktime (0, 0, 0, date (m), date (d), date (Y); ***** simulate the dateadd function in sqlserver * SQL
// It is inconvenient to process dates in PHP, for example, to find the month with a different date? What should I do? // File name: date. inc. php3 // before using these two functions, convert the date or date to the timestamp type. // For example: // $ todaymktime (0, 0, 0, date (m), date (d), date (Y )); /*** simulate sqlserver EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Simulate two date processing
Comparison of common functions of SQL Server and Oracle
--------- Mathematical functions1. Absolute ValueS: select abs (-1) valueO: select abs (-1) value from dual2. INTEGER (large)S: select ceiling (-1.001) valueO: select ceil (-1.001) value from dual3. Round (small)S: select floor (-1.001) valueO: select floor (-1.001) value from dual4. Round (truncation)S: sel
point--String intercept SUBSTRINGSelect substring (' ABCDEFG ', 2, 3); Intercept 3 bits starting from 2nd, index starting from 13. Time-Date function:--Get current system time GetDate ()Select GETDATE ();Sysdatetime () Gets the timestamp of the database service--Get Month daySelect year (' 1999-1-1 ');--Determine if the date is correct, isdate return bitSelect IsDate (' 2000-2-31 ') returns the bit type, False is 0,true is 1--Add Time DateAddSelect DATEADD (year,5, ' 2000-1-1 '); Add what type,
click " recommend " in the lower right corner. If you want to find my new blog more easily, click on " Follow me " If you want to give me more encouragement, you may wish to click on the right, " enjoy your stay" Blog is his own summary of the results of learning, learning to summarize the knowledge-"analysis of the problem-" to solve the problem. Where the views/descriptions in the text are incorrect, please correct them. Thank you for your reading, if you are interested in the content of my b
Two uses of functions in SQL Server (which can be used in place of cursors)
1. Because the update can not use stored procedures, but to update the table based on some of the fields to be calculated. We often use the method of the cursor, which is implemented using the method of the function.
Function section:
以下是引用片段: CREATE FUNCTION [DBO].[FUN_GETTIME] (@TASK
' Union All Select 'Seven' Union All Select '呥' Union All Select 'SA' Union All Select 'his' Union All Select '屲' /*no ' u '*/ Union All Select '屲' /*No ' V '*/ Union All Select '屲' Union All Select 'XI' Union All Select 'ya' Union All Select 'as' Union All Select @chn) asAOrder byCHN COLLATE chinese_prc_ci_as) asbElse Set @c=@chn Set @return=@return+@c End /*While Loop ends*/ return(@return) End /*End of function implementation*/How to use:UP
1. Get the current timeSELECT GetDate ();2. Get time in separate years, months, days and hours, minutes, secondsYear (GetDate ()) part of the current timeMonth (GetDate ()) monthly part of the current timeDay part of the current time (GetDate ())The above function, in turn, returns the value of type int, which returns nvarcharDatename (year, GetDate ())Datename (MONTH, GetDate ())Datename (Day, GetDate ())3. Calculate a time interval of two date typesDATEDIFF (year, ' 2013-01-01 ', ' 2014-01-01
return value of 1 indicates correct--A return value of 0 indicates an errorSelect ISDATE (' 2012-2-29 ')Select ISDATE (' 2008-80-8 ')--sysdatetime system Precise TimeSelect Sysdatetime ()SELECT GETDATE ()--the difference is accurate or notSecond, type conversion function--Data type conversion cast convert--cast writes the converted value + as + the type converted toSelect CAST (1.73 as int)Select CAST (1.73 as varchar (50))Select CAST (1.73333333 as Decimal (18,2))Select cast (CAST (' 1.78 ' as
Label:Definition of UDFSimilar to stored procedures, user-defined functions are also an ordered set of T-SQL statements, and UDFs are pre-optimized and compiled and grams as a unit of love. The main difference between UDFs and stored procedures is how the results are returned. You can pass in parameters when using UDFs, but not outgoing parameters. The concept of an output parameter is replaced by a more ro
Date and time functions in SQL Server
1. Current system date, time
Select GETDATE ()
2. DateAdd returns a new datetime value on the basis of adding a period of time to the specified date
For example: Add 2 days to date
Select DATEADD (day,2, ' 2004-10-15 ')--back: 2004-10-17 00:00:00.000
3. DateDiff returns the number of date and time boundaries across two
"Custom Functions" is our usual term, and "user-defined Functions" is a written version of SQL Server.
SQL Server 2000 allows users to create custom functions, and custom
"Custom Functions" is our usual term, and "user-defined Functions" is a written version of SQL Server.
SQL Server 2000 allows users to create custom functions, and custom
conversion from decimal to 36 can be supported by the above example modification:--decimal conversion to hexadecimalCREATE FUNCTIONBIGINTTO36HEXSTR (@value BIGINT)RETURNS VARCHAR( -) asBEGIN DECLARE @seq CHAR( $) DECLARE @result VARCHAR( -) DECLARE @digit CHAR(1) SET @seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' SET @result = SUBSTRING(@seq, (@value% $)+1,1) while @value > 0 BEGIN SET @digit = SUBSTRING(@seq, ((@value/ $)% $)+1,1) SET @value = @value/ $
Tags: style color using IO strong AR data CTI codeIn SQL Server, users can not only use standard built-in functions, but also use their own defined functions to implement some special functions. Can be created using the Create FUNCTION statement. It is important to note that
syntax structure:
1. Cast
Syntax structure: CAST (expression as data_type [(length)])
2. Convert
Syntax structure: CONVERT (data_type [(length)], expression [, style])
3. Parse
Syntax structure: PARSE (string_value as data_type [USING culture])
Where Parse is a new feature of SQL Server expression must be a string form of the converted Type
Performance Analysis:
Summarize:
1. The difference between Co
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.