[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • Last Modified:

Trigger to capitalize

Write a trigger that will capitalize the first and last names of customers inserted into the Persons table.  Write one or more statements that will fire the trigger when a record is inserted.
0
jphilli
Asked:
jphilli
  • 2
1 Solution
 
Lee SavidgeCommented:
I've seen this request a number of time and you will have trouble. In principle your code is simple:

declare @firstname nvarchar(100), @lastname nvarchar(100)

select @firstname = 'fred', @lastname = 'bloggs'

select upper(left(lower(@firstname), 1)) + right(@firstname, len(@firstname) - 1), upper(left(lower(@lastname), 1)) + right(@lastname, len(@lastname) - 1)



Taking Western style names as examples and you'll run into problems:

O'Toole
McDonald
MacIntyre
Macintyre
van den Heever
Van De Casteele

etc.

There are always exceptions to the rule.
0
 
Lee SavidgeCommented:
Double-barrelled names cause issues as well and there are triple barrelled ones around.
0
 
sarabhaiCommented:
can u specify the table on that trigger will fire and other table name in that data will save.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now