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.
Michael writes "I have created a smaller version of what I am trying to do, but have been scratching my head for 2 days now on this, it seems logical, but I just can't seem to get it to work .. I hope it makes sence and hope you can help .. Thanks and Kindest Regards Mikecreate table tblTable (row char(1),seat char(1))godeclare @booking char(3)set @booking = 'ia6'CASE WHEN SUBSTRING(@booking, 1, 1) = 'i' then insert into tblTable (row,seat) values (SUBSTRING(@booking,2,1), SUBSTRING(@booking,3,1))ELSE WHEN SUBSTRING(@booking, 1, 1) = 'd' then delete from tblTable where row = SUBSTRING(@booking,2,1) and seat = SUBSTRING(@booking,3,1)end"
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2006-04-17 : 10:46:53
use IF ... ELSE insteadKH
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2006-04-17 : 10:47:46
Something like
If SUBSTRING(@booking, 1, 1) = 'i' insert into tblTable (row,seat) values (SUBSTRING(@booking,2,1), SUBSTRING(@booking,3,1))else If SUBSTRING(@booking, 1, 1) = 'd' delete from tblTable where row = SUBSTRING(@booking,2,1) and seat = SUBSTRING(@booking,3,1)
MadhivananFailing to plan is Planning to fail
jen
Master Smack Fu Yak Hacker
4110 Posts
Posted - 2006-04-18 : 01:53:27
or you can create 2 separate sprocs for this since they are different in logic anyways,they'll be easier to debug and maintainHTH--------------------keeping it simple...