Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Functions in Parameters

ChrisMWChrisMW Member Posts: 1
Does anyone know if you can use a function to set the value of an optional parameter? I get a syntax error with the following line in my stored procedure:

@sortyear int = Year(GetDate())

Thanks!

Comments

  • veluguvelugu Member Posts: 3
    : Does anyone know if you can use a function to set the value of an optional parameter? I get a syntax error with the following line in my stored procedure:
    :
    : @sortyear int = Year(GetDate())
    :
    : Thanks!
    :

    I am not sure if your syntax is right

    try

    Declare @sortyear int
    select @sortyear = Year(GetDate())



  • GideonOmegaGideonOmega Member Posts: 617
    : : Does anyone know if you can use a function to set the value of an optional parameter? I get a syntax error with the following line in my stored procedure:
    : :
    : : @sortyear int = Year(GetDate())
    : :
    : : Thanks!
    : :
    :
    : I am not sure if your syntax is right
    :
    : try
    :
    : Declare @sortyear int
    : select @sortyear = Year(GetDate())
    :
    :
    :
    :
    velugu is right you need to declare all variables used in procedures and what not, also you could use the set command like so
    Set @sortyear = Year(getdate())
Sign In or Register to comment.