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 |
Mishenata
Starting Member
2 Posts |
Posted - 2010-08-09 : 11:40:16
|
I'd like to write a procedure that will take the data from an 'Import' table with Select (Id, Name, City, Salary) and update and insert that data in another table 'MonthsImports'. Need Help Please.. quote: CREATE PROCEDURE p_MonthImportsAS BEGINDECLARE id INTDECLARE name NVARCHAR(10)DECLARE salary INTDECLARE city NVARCHAR(10)DECLARE cur_client CURSOR FORSELECT id,name,salary,city from ImportOPEN cur_client.........................
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-08-09 : 11:42:22
|
[code]INSERT INTO MonthsImportsSELECT Id, Name, City, Salary FROM ImportTable[/code] |
 |
|
Mishenata
Starting Member
2 Posts |
Posted - 2010-08-10 : 03:07:21
|
Every month the Import table is filled with the current information about the salaries. I have to store the whole history concerning the salaries in another table. For this purpose, I need to write a stored procedure that will Select all the records and fields from the monthly Import table and Update or Insert 'MonthsImports' where the History will be stored.Import table:id | name | salary | city(in oracle I use: merge into MonthsImports MI using (select...) when matched then update.. when not matched then Insert ..) |
 |
|
Lumbago
Norsk Yak Master
3271 Posts |
|
|
|
|