I am trying to write my first SQL query against a database to pull a list of users. I am using Crystal Reports, and when I go thru the report builder and then run it I get the above error.
When I look at the SQL Query I see this:
SELECT
User."Disabled", User."UserName"
FROM
"Database"."dbo"."User" User
ORDER BY
User."UserName" ASC
I saw other articles saying user needs to be in Brackets so I did this:
SELECT
User."Disabled", User."UserName"
FROM
"Database"."dbo"."User" [User]
ORDER BY
User."UserName" ASC
When I do that I then get an error message that says:
Cannot call methods on nvarchar
Can someone please help me figure out what I am doing wrong here?
Thanks,
Why are you using double quotes at all? I would start with:
SELECT u.Disabled, u.UserName
FROM Database.dbo.User u
ORDER BY u.UserName ASC
You don't specify your database, but words like User
are often reserved words, so they make a poor choice for an identifier name.
Like it was suggest in error message: User is keyword. You can replace User
alias you are using with simple u
. Like:
SELECT u."Disabled", u."UserName"
FROM "Database"."dbo"."User" u
ORDER BY u."UserName" ASC
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.