April 5, 2004 at 7:55 am
Here is the noob question of the day.
How can I do to always convert to UPPERCASE all inserts & updates over a table?
I thougt first in a FOR INSERT, UPDATE trigger, but seems to not be possible to edit INSERTED values.
I've missed something?
April 5, 2004 at 8:12 am
Use the UPPER function.
Francis
April 5, 2004 at 8:16 am
Yes, I know, but this table is used by many apps (some not mine), so use UPPERCASE in all SQL instructions is not an option.
April 5, 2004 at 8:33 am
update column value instead.
Here is sample case.
use pubs
go
create table uppercase (c1 varchar(100))
go
create trigger trg_uppercase on uppercase
instead of insert
as
begin
insert uppercase select upper(c1) from inserted
end
go
insert uppercase values('qwe32Rt')
go
select * from uppercase
go
drop trigger trg_uppercase
drop table uppercase
April 5, 2004 at 8:37 am
AS you said use INSTEAD OF trigger but use the UPPER function. You do not edit the Inserted table you just insert the UPPER of the values as in:
CREATE TRIGGER IO_Trig_INS_Employee ON Employees
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON
INSERT INTO Employees
SELECT UPPER(LastName), UPPER(FirstName), UPPER(Title), TitleOfCourtesy, BirthDate
,HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, Photo
,Notes, ReportsTo, PhotoPath
FROM INSERTED
END
Francis
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply