sql server - passing unquoted constants to functions like DATEPART does

后端 未结 2 1325
终归单人心
终归单人心 2021-01-19 12:57

i would like to create a function which accepts a constant like the datepart function accepts yy/mm/dd/hh/

like:

select datepart(

2条回答
  •  时光取名叫无心
    2021-01-19 13:49

    i would like to create my own function that accepts dd not char like 'dd'

    I think you're out of luck on this. If you don't single-quote the characters, they'll be interpreted as a name--but you can't have defined them as a name anywhere if you want them to be used in the manner you propose.

提交回复
热议问题