Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL view statement

Author  Topic 

Venk
Starting Member

6 Posts

Posted - 2013-11-16 : 16:50:28
Hi

Working on a query to display books and the authors who wrote them. The following query gives an error message. Can anyone help? - thanks

Create View AuthorBooks
As SELECT Title, Author
FROM Books
Where Category = 'Author';

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-11-16 : 23:03:31
What's the error? I don't see a problem with that code.

Be One with the Optimizer
TG
Go to Top of Page

Venk
Starting Member

6 Posts

Posted - 2013-11-17 : 01:04:31
quote:
Originally posted by TG

What's the error? I don't see a problem with that code.

Be One with the Optimizer
TG



It says invalid identifier
Go to Top of Page

Venk
Starting Member

6 Posts

Posted - 2013-11-17 : 01:05:14
quote:
Originally posted by TG

What's the error? I don't see a problem with that code.

Be One with the Optimizer
TG



I mean it says "Author" invalid identifier
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-11-17 : 01:10:05
are you using Microsoft SQL Server ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Venk
Starting Member

6 Posts

Posted - 2013-11-17 : 01:57:45
quote:
Originally posted by khtan

are you using Microsoft SQL Server ?


KH
[spoiler]Time is always against us[/spoiler]





Yes, but when i use Read Only instead of Author I do not get any error message
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-11-17 : 02:48:36
what do you mean "use Read Only" ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Venk
Starting Member

6 Posts

Posted - 2013-11-17 : 02:52:14
quote:
Originally posted by khtan

what do you mean "use Read Only" ?


KH
[spoiler]Time is always against us[/spoiler]





Using With Read Only; instead of Where Category = 'Author'; at the end of the syntax
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-11-17 : 08:55:12
can you show us the "read only" code ?

Also can you post your table DDL, some sample data ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -