Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

How to configure a computed column that uses two related tables at table design time

$
0
0

--SQLServer 2008'R2

I have two related tables one to many relationship dbo.days which holds 'Monday' through 'Friday', so dbo.dayid.3 would be 'Wednesday'

and dbo.worklog both related on dbo.Day.DayID and dbo.worklog.DayID

I tried to set up the computed field for dbo.worklog.day like so:

Computed Column specification: dbo.worklog.day=dbo.days.day

The reason is I want the field dbo.worklog.day to auto populate with the string value 'Monday', 'Tuesday', etc when I enter worklog data.

But the designer comes back with error saying expression cant be used etc

I have hunted around a bit trying to find the right syntax for this expression, but it seems many people are saying I need to use a User defined function. If so how do I write such an expression to reference a field in a related table and what parameter if any do I pass into it?. If I have to use a UDF how do I call it from the designer?

I'm just trying to gain a better understanding of computed fields

Thank you in advance for your valuable time :)


paul




Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>