September 1, 2008 at 4:00 am
Hi! I need an update table syntax to Update the table with new records or update the existing records based on the Staffno, together with the period indicator
September 1, 2008 at 4:21 am
do u mean this? update table_name set col1 = valu1, col2 = value2 where staffno = staff_value and period = period_value
September 1, 2008 at 4:47 am
Could you give us a little more info? The table structure, some sample rows from that table and an example of what you want the result to look like?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 1, 2008 at 5:01 am
OK.
I have a table IRchair which has columns staffno and clusterid. I am going to add to this table a clumn named period. So I need to bring into this table data for different periods(eg. jan, feb, march ....) without duplicating data.
If a certain staffno exist in that table then I don't want to bring it in again
September 1, 2008 at 5:44 am
thatok (9/1/2008)
OK.I have a table IRchair which has columns staffno and clusterid. I am going to add to this table a clumn named period. So I need to bring into this table data for different periods(eg. jan, feb, march ....) without duplicating data.
If a certain staffno exist in that table then I don't want to bring it in again
Can you please give us the table's structure (as a create table statement is easiest), some sample data and what you want it to look like after the update?
Where are you data on the different periods from?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 1, 2008 at 6:58 pm
thatok (9/1/2008)
OK.I have a table IRchair which has columns staffno and clusterid. I am going to add to this table a clumn named period. So I need to bring into this table data for different periods(eg. jan, feb, march ....) without duplicating data.
If a certain staffno exist in that table then I don't want to bring it in again
It's called an UPSERT or MERGE... without more data, my only suggestion would be to Google those two words.
For better quicker answers, you may want to take the time to read the article at the link in my signature below.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 2, 2008 at 1:36 am
Thanks. That's exactly what I was looking for. Thanks everyone for your input
September 2, 2008 at 7:27 pm
Thanks for the feedback...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply