Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi, In my application am having tableselect * from ctlServiceLevel displays some times 1 record or 0 recordi dont want to use insert statement...UPDATE ctlServiceLevelSET DATABASENAME = 'COMMON', DATE = '09/01/2009', LASTSL = 87.88 i want to update a table when the table contains 0 records or it contains recordshow to achieve this please suggest me........
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2009-09-02 : 08:32:47
Then when do you want to insert?MadhivananFailing to plan is Planning to fail
vision.v1
Yak Posting Veteran
72 Posts
Posted - 2009-09-02 : 08:43:48
quote:Originally posted by madhivanan Then when do you want to insert?MadhivananFailing to plan is Planning to fail
Irrespective of the data present in the table or not, i want to execute the above update statement..Is it possible??thanks for reply
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-09-02 : 08:50:51
quote:Originally posted by vision.v1
quote:Originally posted by madhivanan Then when do you want to insert?MadhivananFailing to plan is Planning to fail
Irrespective of the data present in the table or not, i want to execute the above update statement..Is it possible??thanks for reply
if there's no records, then what will you update? or do you want to insert in that case?
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-09-02 : 08:54:53
if yes, this is what you want
UPDATE ctlServiceLevelSETDATABASENAME = 'COMMON',DATE = '09/01/2009',LASTSL = 87.88 IF @@ROWCOUNT=0BEGININSERT INTO ctlServiceLevel(DATABASENAME,DATE ,LASTSL)VALUES ('COMMON','09/01/2009',87.88 )END