Discover sql server format function, include the articles, news, trends, analysis and practical advice about sql server format function on alibabacloud.com
/********************************************** timestamp conversion (seconds) **********************************************/--normal time conversion to timestamp (seconds)SELECT DATEDIFF(SS,'1970-1-1 00:00:00',GETDATE()) --millisecond timestamp to normal time (seconds)SELECT DATEADD(SS,1447842393,'1970-1-1 00:00:00')/********************************************** Timestamp conversion (ms) **********************************************/--normal time conversion to timestamp (MS)DECLARE @ADATE DA
Looking for a ready-made function, I found that SQL Server users are lazy than me, and I don't even have this basic function! Good, because all I need is the serial number and it will be reset every month, and the maximum ordinal number will not exceed 0.1 million. So use Ribao: declare @ SNintdeclare @ SNLenintset @ S
Label:When the amount of text data is relatively large, the input of a strip is basically impossible, and writing a program to relay it is also very troublesome, fortunately SQL Server provides a relatively concise method.Bulk Insert table name from ' C + + your text file. txt ' with (fieldterminator = ' What symbol to split the data ', rowterminator= ' with what symbol plus \ n End ') --\n is the meaning
We often use a variety of date formats for some purpose. Of course, we can use string operations to construct various date formats, but why are there any ready-made functions?
The default datetime format of the Chinese version of SQL Server is yyyy-mm-dd thh: mm: Ss. Mmm.
For example:
Select getdate ()
11:06:08. 177
I sorted out the date
The default datetime format of the Chinese version of SQL Server is yyyy-mm-dd thh: mm: Ss. Mmm.For example:Select getdate ()11:06:08. 177I sorted out the date format conversion methods that may be frequently used in SQL Server:Example:Select convert (varchar, getdate (), 12
Label:SELECT CONVERT (varchar), CAST (@testFloat as Decimal (38,2)))SELECT STR (@testFloat, 38, 2) Import from Excel to sql2000, there is a column "contact" has become a float type, I want to convert to nvarchar type, with the following statement Select convert (nvarchar (+), convert (int, contact)) from employeeGo Data overflow, no! Select convert (nvarchar), CONVERT (Decimal (11,0), contact) from employeeGo Data Conversion Success! SELECT CONVERT (nvarchar), CAST (Contact as decimal (11,
I used a stupid method, but I don't know if there are other good methods:
Compare the field to be modified with the field in the stored procedure and change it to the same size, the same type, and the order to be completely the same. This still does not work, and re-compilation is not successful, when SQL Server is stopped and restarted, some parameters in the stored procedure can be used as annotations, r
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.