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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Define unique column on view

Author  Topic 

mattt
Posting Yak Master

194 Posts

Posted - 2010-02-17 : 06:03:43
Hi,

I've created a view using the following T-SQL:


SELECT dbo.Product.Name, dbo.Product.ShortDescription, dbo.Product.FullDescription, dbo.ProductOption.Name AS ProductOption,
dbo.ProductOptionValue.Name AS OptionValue, dbo.SkuVsProductOptionValue.ID AS UniqueKey, dbo.Sku.SkuCode, dbo.Product.Id
FROM dbo.Product WITH (nolock) INNER JOIN
dbo.Sku WITH (nolock) ON dbo.Product.Id = dbo.Sku.Product_id INNER JOIN
dbo.SkuVsProductOptionValue WITH (nolock) ON dbo.Sku.Id = dbo.SkuVsProductOptionValue.Sku_id INNER JOIN
dbo.ProductOptionValue WITH (nolock) ON dbo.ProductOptionValue.Id = dbo.SkuVsProductOptionValue.ProductOptionValue_id INNER JOIN
dbo.ProductOption WITH (nolock) ON dbo.ProductOption.Id = dbo.ProductOptionValue.ProductOption_id


As you might imagine the column "UniqueKey" is unique and non-null. But when I try to define a full text index using the wizard, I get told that "A unique column must be defined on this table/view". Do I need to do something in order to indicate that UniqueKey is indeed Unique, or am I missing something else?

Cheers,
Matt

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-17 : 06:22:56
have you created a unique index on it?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-17 : 06:58:48
" WITH (nolock) "

Scares me to death when I see code peppered with that ...

... use READ_COMMITTED_SNAPSHOT instead (I think that was available in SQL 2005, rather than just from SQL 2008?)
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-02-17 : 07:03:17
yeah it's available in 2005. and very useful!

matt -- maybe post the table definitions. Just script them out will suffice.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -