April 17, 2012 at 2:27 pm
for example I have a table, which has ID, Service, Subservice cols.
I want to modify or change 'Surgery Service' to 'XXX-Surgery' for the "Service" col where ID = 123,
and from 'PEDI' to 'PEDI-SURGERY' for the "subservice" col where ID = 123
Thanks
April 17, 2012 at 2:40 pm
It seems like a simple update
declare @t table (
ID int, Service nvarchar(30), Subservice nvarchar(30))
insert into @t
select 123, 'Surgery Service', 'Test' union all
select 123, 'Surgery Service', 'PEDI' union all
select 123, 'Surgery', 'PEDI' union all
select 124, 'Surgery Service', 'Pedi'
select * from @t
update @t
set Service = case when Service = 'Surgery Service' then 'XXX-Surgery' else Service end,
Subservice = Case when Subservice = 'Pedi' then 'PEDI-SURGERY' else Subservice end
where ID = 123
select * from @t
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
April 17, 2012 at 2:42 pm
hbanerje (4/17/2012)
for example I have a table, which has ID, Service, Subservice cols.I want to modify or change 'Surgery Service' to 'XXX-Surgery' for the "Service" col where ID = 123,
and from 'PEDI' to 'PEDI-SURGERY' for the "subservice" col where ID = 123
Thanks
Please provide the DDL (CREATE TABLE statement), sample data (series of INSERT INTO statements), expected output, and the code you have written so far to solve the problem.
April 17, 2012 at 8:16 pm
hbanerje (4/17/2012)
for example I have a table, which has ID, Service, Subservice cols.I want to modify or change 'Surgery Service' to 'XXX-Surgery' for the "Service" col where ID = 123,
and from 'PEDI' to 'PEDI-SURGERY' for the "subservice" col where ID = 123
Thanks
Mike01 gave a good answer on this. My feeling is that you're pretty new to SQL and I'd like to help you learn a bit more about it. Do you know what "Books Online" is and how to get into it?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply