Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
LGOOLSBY
Starting Member
4 Posts |
Posted - 2006-01-27 : 09:52:31
|
| This is my first attempt at writing a Stored Procedure and am hoping somebody might walk me through this. I think it is probably simple, I have just never done it (ussually not a task of mine.)I have 2 tables, one created from the other. We will call them Table1 and Table2 (Table2 built from Table1.) On a somewhat regular basis, I need to loop through all records in Table1 and add any records to Table2 that currently do not exist. Table2 has only 3 fields from Table1 plus a few others that are used by another application.Lee |
|
|
Jothikannan
Starting Member
36 Posts |
Posted - 2006-01-27 : 10:04:25
|
| sorry, i m not understand u'r Question but i think u'r Looking Like thisinsert table2 (col list....)select col list....From table1(nolock)where Not Exists(select 'x' from table2(nolock) where table1.col=table2.col --Add U'r conditions here ) |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-01-27 : 10:09:21
|
| If u r a beginnerU start by writing a simple stored procedure 1. learn how to insert data to a table using a hard coded query2. modify the SP to accept parameters3. learn how to insert data to a table using passed parameters4. learn how to insert data to a table from another table5. learn how to check whether one table has same data as of the other6. learn how to select data based based on conditions (data exists in tbl1 not in tbl2)7. learn how to insert data from a table along with some other data (passed as parameters)8. combine all above and achieve ur target |
 |
|
|
|
|
|