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 |
|
JeffS23
Posting Yak Master
212 Posts |
Posted - 2008-06-09 : 13:49:09
|
| I need help writing an update script in SQL 2005. My client sent me a list of codes in an excel file they would like to add to these tables. The excel sheet is not big at all. I need to write in my update script somehow to first check if these values exist and if not, update the tables. Any help is greatly appreciated. I would perfer not importing the excel sheet if possible. I had to set the SET IDENTITY INSERT ON to just enter this in my demo database. Any insight on this too would be helpful SET IDENTITY_INSERT cusImmunCodes ONINSERT INTO cusImmunCodes ( cusImmunCodesID, Code, Description, CatCode, Created, CreatedBy, LastModified, LastModifiedBy ) VALUES ( /* cusImmunCodesID - int */ 84, /* Code - varchar(10) */ '90636', /* Description - varchar(35) */ 'Hep A & B (adult dose)', /* CatCode - int */ 42, /* Created - datetime */ GETDATE(), /* CreatedBy - varchar(30) */ 'CYS_SCRIPT', /* LastModified - datetime */ GETDATE(), /* LastModifiedBy - varchar(30) */ 'CYS_SCRIPT' ) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
JeffS23
Posting Yak Master
212 Posts |
Posted - 2008-06-09 : 13:51:54
|
| I hit enter to quick ... question posted now. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-09 : 14:06:44
|
| [code]IF NOT EXISTS (SELECT * FROM cusImmunCodes WHERE cusImmunCodesID=@ID)BEGININSERT INTO cusImmunCodes (cusImmunCodesID,Code,Description,CatCode,Created,CreatedBy,LastModified,LastModifiedBy) VALUES (@ID,othervalues...)ENDELSEBEGINUPDATE cusImmunCodesSET Code=value2,Description=value3,...WHERE cusImmunCodesID=@IDEND[/code] |
 |
|
|
|
|
|
|
|