(Select replace (CONVERT (varchar, GETDATE (), +), '-', '), ', '), ': ', ') + (select Right (CONVERT ( varchar (+), GETDATE (), 126), 3) as [UserID])
Reproduced below from: http://blog.sina.com.cn/s/blog_4605821b010005qj.html
1. Learn the functions of SQL intercept string
The most commonly used interception function is left,right,substring
1.LEFT ( character_expression , integer_expression )
Returns the specified number of characters starting from the left of the string
Example: Left ("field name", intercepting several strings)
The following example uses the left function to return the leftmost 2 character of a string abcdefg.
SELECT LEFT(‘abcdefg‘,2)GO
Here is the result set:
-- ab
2。RIGHT ( character_expression , integer_expression )
返回字符串中从右边开始指定个数的 integer_expression 字符
举例说明:RIGHT(“字段名”,截取几位字符串)
The following example uses the right function to return the rightmost 2 character of a string abcdefg.
SELECT right(‘abcdefg‘,2)GO
Here is the result set:
-- fg
3.SUBSTRING ( expression , start , length )
返回字符、binary、text 或 image 表达式的一部分
举例说明:SUBSTRING(“字段名”,第几位开始,截取几位字符串)
Displays the second, third, and fourth characters in a string constant abcdef.
SELECT x = SUBSTRING(‘abcdef‘, 2, 3)
Here is the result set:
x----------bcd
SQL time and string is taken to the millisecond level