Home > Forum > Rules, JS, SQL > ##currentloginname## in SQL filter for Report gives error

##currentloginname## in SQL filter for Report gives error
1

I'm struggling with the syntax of the SQL filter for a report.
In general it works, but if I want to use the currently loggedin user, I get an error.
I tried with the following syntax:

AND (##currentloginname##='servr\Userxxx')

The error message is:
"Incorrect syntax near '='. Incorrect syntax near ','. Incorrect syntax near the keyword 'order'."

MVP

Hi Klaus,


there's a simple issue in your query, the variable needs to be enclosed in '':

Before: AND (##currentloginname##='servr\Userxxx')
After: AND ('##currentloginname##'='servr\Userxxx')

Unfortunately there's a small issue with the variables:
Once the report is saved a space character is added at the end
Before save: AND ('##currentloginname##'='servr\Userxxx')
After save: AND ('##currentloginname## '='servr\Userxxx')

You can work around this issue with the following
and (RTrim('##currentloginname##') = 'server\user')

Best regards,
Daniel

Privacy overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognizing you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.


To see a full list of the cookies we use and learn more about their purposes, visit our Privacy Policy.