Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why some system functions in T-SQL without parameters have parenthesis while others don't?

I never remember if a system T-SQL function, with no parameters, requires parenthesis, so I wonder if there is a reason.

For example: CURRENT_TIMESTAMP is a function that doesn't require parenthesis, while SCOPE_IDENTITY() requires them.

like image 478
sergiom Avatar asked Feb 22 '10 13:02

sergiom


People also ask

Can we create function without parameter in SQL?

How to Create a Function Without a Parameter in SQL. Line one creates a function then named the function “YTDSALES()”. You can give your function any name. Remember to add parenthesis to the name of the function when without a parameter.

How do you execute a scalar valued function in SQL Server with parameters?

Scalar-valued functions can be executed by using the EXECUTE statement. If you EXECUTE a function rather than use it in a SELECT statement or constraint, you can leave out the schema name in the function name, and it will look in the dbo schema followed by the users default schema.


1 Answers

I think the differences are due to whether the function is a part of the ansi sql standard (which current_timestamp is) or whether it is a sql server function.

like image 66
Andrew Avatar answered Oct 13 '22 19:10

Andrew