Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

INSERT INTO FROM RETRIVED DATA Expand / Collapse
Author
Message
Posted Sunday, January 20, 2008 1:59 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Today @ 8:24 AM
Points: 43, Visits: 351
Hi,

I have a task it sounds simple and resonable but when i started working on it i am not able to complete it so i thought finaly i would get some help from here ..


My task is i have to create a stored proc
where we pass a parameter which Retrives the data from a table(Table A) and Table A has 5 Coloumns
and i have another table(Table B) which is the replica of the table (Table A) with 10 coloumns.
So What i have to do is Retrive the data from Table A insert that Record in Table B along with extra parameteres passed for those extra 5 coloumns

Because Table A and Table B coloumns has only 5 matching coloumns the issue is how to insert data in Table B for those additional 5coloumns


so please give me a solution or any hints or Query's



Thanks

Post #445309
Posted Sunday, January 20, 2008 3:00 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, February 22, 2013 11:13 AM
Points: 69, Visits: 183
not sure i completely understand u. here is the basic:

insert tableB (col1, col2, col3, col4, col5)
SELECT col1, col2, col3, col4, col5
FROM tableA

but if u are passing 5 params to the SP and want to capture those (1) that sounds completely unnecessary as the data should tell u that but...

insert tableB (col1, col2, col3, col4, col5, col6, col7, col8, col9, col10)
SELECT col1, col2, col3, col4, col5, @param1, @param2, @param3...
FROM tableA
WHERE col1 = @param1
And col2 = @param2
....
Post #445310
Posted Sunday, January 20, 2008 3:38 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 8:32 AM
Points: 31,433, Visits: 13,747
This sounds like a homework assignment. Please make your own attempt at this and show some effort.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #445312
Posted Wednesday, December 28, 2011 5:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, December 12, 2012 8:44 PM
Points: 1, Visits: 46
''This query take whole back up of table
Select * into table1 from table
Post #1227301
Posted Wednesday, December 28, 2011 6:45 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, May 15, 2013 2:05 PM
Points: 2,013, Visits: 1,566
deepuduvedi (12/28/2011)
''This query take whole back up of table
Select * into table1 from table


Posted Monday, January 21, 2008 2:29 AM


~Dev~
Post #1227320
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse