Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««12345

VIEWS 3 Expand / Collapse
Author
Message
Posted Wednesday, October 10, 2012 1:58 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 4:03 AM
Points: 3,956, Visits: 5,186
kapil190588 (10/10/2012)
sorry I pasted wrong query-
this is the query below in which I am getting error-
alter view chk_sales
as
select * from SalesDates,
add constraint chk_unique unique values (id>2)

You cannot create a constraint on the columns of a view.
Constraints belong on the base tables.
Views make use of predicates...


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1370747
Posted Wednesday, October 10, 2012 3:46 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:46 PM
Points: 5,998, Visits: 8,261
kapil190588 (10/10/2012)
can anyone tell me how to add a constraint to a already created view?
I write as-
alter view chk_sales
as
select * from SalesDates,
add chk_unique constraint unique (id>2)

this is giving me error...

You cannot create any constraints on views,
You can, however, create indexes on views. The first one you create has to be a clustered unique index; after that you can continue to create additional nonclustered indexes, that can be unique or nonunique, can include additional columns, and can be filtered. Using unique indexes on a view is a way to mimic the behaviour of constraints - but my recommendation is to do this only when required (which, since the addition of filtered indexes in SQL Server 2008, should be almost never); it's much better, both for performance and for future maintenance, to put constraints on the base tables.



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1370801
Posted Wednesday, October 10, 2012 3:56 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 3:27 AM
Points: 1,890, Visits: 2,329
hi Hugo,
thanks a lot....
I am new in area of DBA so can you plz suggest how can i improve my skills in sql area..
any site or books?



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1370805
Posted Wednesday, October 10, 2012 5:04 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:46 PM
Points: 5,998, Visits: 8,261
kapil190588 (10/10/2012)
hi Hugo,
thanks a lot....
I am new in area of DBA so can you plz suggest how can i improve my skills in sql area..
any site or books?

The most important thing is to get practice. As much as you can get. If you haven't already, install an instance of SQL Server on your private laptop and/or home desktop. SQL Server Express edition is a free download that enables you to play around with most features; if you need acccess to the full feature set, you can buy Developer Edition for, I think, about 50 dollars per license. (I think you will need one license for each computer you install it on). Developer Edition gives you access to the full feature set of Enterprise Edition, but the license does not cover production use - development and testing only.

It's also very important to know where to ask for help. Always try to find a solution first, using Books Online, trial and error, and Google/Bing - but don't hesitate to ask for help if needed. There are forums on this site, but there are also forums on many other sites. The most popular are probably the MSDN forums. Also, if you're on Twitter, you can get quick answers to short questions by using the #sqlhelp tag.

For reading, I can recommend lots of sites. MSDN is mostly reference. This site has lots of articles, but unfortunately, the quality varies from extremely good to extremely bad, and everything in between. When you read an article here, always check if there was any debate on the forums (each article has a link to it's own forum discussion, just like the daily questions), and then still double check what you read. The daily question here is also nice, but beware that question authors often focus on edge cases, whereas in your actual work you will need the normal stuff most often.

A source of very high quality information is the blogger site sqlblog.com. (And I'm not saying that becuase I blog there, but because there are many great bloggers there - and note that there are also many great bloggers who blog elsewhere, so don't limit yourself to just that one site). However, due to the nature of blogs, it may be hard to find material of your own level.

It's hard for me to recommend books, as I don't read that many books - and those I do read are not really targeted at the beginner level. One book I can recommend wholeheartedly is Paul Nielsens "SQL Server 2008 Bible". (For full disclosure, I will say upfront that I was involved in the production of this book - I was the lead technical editor. I was payed a fixed amount for this, so I have no financial interest in driving its sales). I believe this book does achieve what it sets out to do - cover almost everything in SQL Server, starting at a level suitable for relative newcomers, but not stopping short of the more advanced stuff.
Be warned that this is a pretty hefty volume. Don't plan to read it on a plane, you'll have to pay for excess weight. And check it out before buying, it may be more than you need at this time. I think there is also a "SQL Server 2012 Bible", but I have not seen any of its contents, so I can't comment on the quality. I know that Paul Nielsen, the original author of the "SQL Server ... Bible" series, was no longer involved in this edition.

For more book reading suggestions, you might want to start a new discussion in an appropriate forum and see what other suggestions you get.



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1370846
Posted Wednesday, October 10, 2012 5:13 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 3:27 AM
Points: 1,890, Visits: 2,329
thanks for your suggestion Hugo


_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1370855
Posted Thursday, January 10, 2013 6:15 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, August 4, 2014 5:38 AM
Points: 945, Visits: 558
Nice question and nice reference in answer.. I lost patiencce on reading the entire explaination provided in BOL..

But really a great stuff.


--
Dineshbabu
Desire to learn new things..
Post #1405376
« Prev Topic | Next Topic »

Add to briefcase «««12345

Permissions Expand / Collapse