SQL Server - Set Primary Key to SQL View
Asked By Naresh Kumar on 28-Dec-10 02:35 AM
Can we set the primary key to SQL veiw, if it is possible then please help me.
Thanks in advance.
Gorav Handa replied to Naresh Kumar on 28-Dec-10 02:41 AM
You can not add a primary key constraint to views.
You can join columns though. In the join condition, you do not have to use a
primary key constraint.
FROM view1 v1
INNER JOIN view2
ON v1.vendor_id = v2.vendor_id
The type of join to use is based
upon your data requirement. In the example above, I am using an inner join. But
you'd have to tell us what you want in order for us to help.
Naresh Kumar replied to Reena Jain on 28-Dec-10 02:54 AM
Thanks for your reply,
I am creating a Report model which displays all the columns in the view, but while creating this it is asking for Primary key.
Can you please let me know how can I accomplish this.