Author |
Topic |
eddietwal
Starting Member
5 Posts |
Posted - 2014-08-10 : 01:26:32
|
I have 2 tablesFirst Table is CUSTOMERS with the columns (CustomerId, CustomerName) Second Table is LICENSES with the columns (LicenseId, Customer) The column customer from the second table is the CustomerId from the First tableI wanted to create a store procedure that insert values into table 2Insert into Licenses (Customer) Values( Same As CustomerId) HOW i can get this data from the other table? Thanks For the Help in Advance |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-10 : 08:03:15
|
Use a select clause |
|
|
eddietwal
Starting Member
5 Posts |
Posted - 2014-08-10 : 11:31:46
|
I don't think thats what I need here. |
|
|
Chris_Kelley
Posting Yak Master
114 Posts |
Posted - 2014-08-10 : 18:00:26
|
c |
|
|
Chris_Kelley
Posting Yak Master
114 Posts |
Posted - 2014-08-10 : 18:05:05
|
c |
|
|
b8538230
Starting Member
16 Posts |
Posted - 2014-08-10 : 18:38:06
|
quote: Originally posted by eddietwal I don't think thats what I need here.
e.g.insert into sometable(col1, col2, col2)select col1, col2, col3from someothertable |
|
|
eddietwal
Starting Member
5 Posts |
Posted - 2014-08-10 : 21:03:54
|
Chris,nice idea but it only works one time because the second time you run the sp you get an error (Subquery returned more than 1 value. ) |
|
|
Chris_Kelley
Posting Yak Master
114 Posts |
Posted - 2014-08-10 : 21:11:43
|
c |
|
|
eddietwal
Starting Member
5 Posts |
Posted - 2014-08-10 : 21:27:47
|
I'm sure its going to be a simple solution. I will find out when I get to work tomorrow morning. I will ask one of the seniors. I will post back the solution later on tomorrow. |
|
|
Chris_Kelley
Posting Yak Master
114 Posts |
Posted - 2014-08-10 : 22:08:46
|
c |
|
|
eddietwal
Starting Member
5 Posts |
Posted - 2014-08-10 : 23:35:26
|
I will try this now. By the way Customer from the Licenses table is the CustomerId from the Customers table just FYIMeaning that you can't insert any values in the customer field. It takes its data from the cutomerId columnINSERT INTO #LICENSES (LICENSEID, CUSTOMER)VALUES (1,'WAL') you can't fill the customer column it takes it from the other table. |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-08-11 : 07:40:17
|
quote: Originally posted by eddietwal I will try this now. By the way Customer from the Licenses table is the CustomerId from the Customers table just FYIMeaning that you can't insert any values in the customer field. It takes its data from the cutomerId column
but Licenses.Customer is a varchar and Customer.CustomerId is an int. How can they be the same? |
|
|
|