|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
comparing 2 tables
ok i hate to do this, but i need to accomplish this asap.
I have two tables, one has the following fields tbo.employees userid, firstname, lastname. The other has tbo.sales: userid, gross sales,total profit. I need to pull the firstname and lastname fields from the employees table using the userid field as "primary key" not all employees are in the sales table because not all employees are in sales. My boss wants a user defined function to do this. The end result is getting passed to a "data cube" Hope this makes sence. Thank you for any help. |
|
#2
|
|||
|
|||
|
any 1?
|
|
#3
|
||||
|
||||
|
Quote:
this doesn't make much sense what you are asking for is Code:
select firstname, lastname from tbo.employees where userid = 937 |
|
#4
|
|||
|
|||
|
sorry, i am new to this.
tbo.sales only has the userid field. we are adding a field that has the userid and fullname (together as one field) to the tbo.sales. However, we have to retrieve the values firstname and lastname from dbo.employees. I have a stored procedure that i am trying to get to work, but they want it to be a UDF. I hope that is more understandable. here is the stored procedure: UPDATE dbo.sales SET fullname_id = nameidname FROM dbo.employees INNER JOIN DBO.employees ON (dbo.sales.box = DBO.employees.box) AND (dbo.sales.userid = DBO.employees.userid) Also, each store has a "box" number. So the userid and box number have to be the same to create a "match" |
|
#5
|
||||
|
||||
|
a UDF to update a column in a table?
you'll need expert advice, i'm not sure how to even approach that you might start by asking whoever said it had to be a UDF and "userid and fullname together as one field"? are you serious? i'm wondering if "they" have any idea what they'rte getting into... perhaps somebody else would like to comment? this is just too weird for me |
|
#6
|
|||
|
|||
|
I understand it is wierd. Thanks for trying though.
At this point im just trying to get the stored procedure to work. getting an error: Invalid column name 'nameidname' nameidname is a UDF. Is it possible to use SET to call a UDF? |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > comparing 2 tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|