martes, 10 de marzo de 2015

Converting DateTime to ID string in SQL

SELECT TOP 10 CONVERT(VARCHAR, Registration_date, 112) + REPLACE(SUBSTRING(CONVERT(VARCHAR, Registration_date, 114),1,8),':','')
FROM [TableName]

Result format: - yyyyMMddHHmmss -

20150414131724
20150414152927
20150414174656