Skip to content
Advertisement

Why CAST from Date time to varchar works in one Environment but not the other?

For this questions, we have two environments, Dev and Prod with both running sql2014 with dev being a developers version and prod an enterprise version. Dev is running the below version(s)

enter image description here

Prod is running the below version(s)

enter image description here

Both are using the same data set (static data set from prod. DB was restored from Prod to Dev today), but when casting from Date/time to Varchar in Dev, its throws a conversation error, but in our Prod environment, it works just fine.

Could the difference in version we see here be the reason it doesnt work in our lower environment.

Here is the Dev Exact version #: SELECT @@Version

Prod Version

Here is my SQL, its apart of a CTE Update statement if wondering what the hell im doing:

Date Types (Both Env):

[trans-date] = (date, null)

[char-old] = (varchar(16), null)

Advertisement

Answer

Issue was actually DB compatibility level. Supposed to be set to 2008 (100) but was 2014 (120). i also go it working in 2014 (120) compatibility by not casting CT.[trans-date] as varchar. Even though that answer wasnt provided, the suggestion helped me trouble shoot so much appreciated!

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement