Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

DatePart function returns a asterisk

$
0
0

I found a DATEPART Function returning an asterisk this morning for a backup job dynamically building the backup path. I just thought I'd share it since I doubt they will fix it.

--Run this in SSMS

select CAST(DATEPART(mm, getdate()) as CHAR(1))

--This returns a '*'   , but it should throw an error for overflow.

--Below is the fix in the string concatenation so it doesn't return a '*'

select CAST(DATEPART(mm, getdate()) as CHAR(2))


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>