10

This SQL:

select FORMAT(lNum,'##-###-##-###') 
from  [rpt].[myView] 

Produces the following error:

Argument data type varchar is invalid for argument 1 of format function.

lNum is a varchar(10)

Running SQL Server 2012

1

1 Answer 1

20

varchar isn't supported as the first argument to FORMAT. The only categories of datatypes supported are Date and Time and Numeric.

You could do

select FORMAT(cast(lNum as numeric),'##-###-##-###') from  [rpt].[myView]  

From levelonehuman's comment : Documentation

Sign up to request clarification or add additional context in comments.

1 Comment

Instead of duplicating the answer, FORMAT on MSDN

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.