Advertisement
Guest User

Untitled

a guest
May 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. create table Students
  2. (
  3. FirstName nvarchar(50) not NULL,
  4. LastName nvarchar(50) not NULL,
  5. MiddleName nvarchar(50) not NULL,
  6. FullName as LastName + ' ' + left(FirstName, 1) + '.' + left(MiddleName, 1) + '.'
  7. )
  8.  
  9. select FullName
  10. from Students
  11.  
  12. FullName as ... persisted
  13.  
  14. create function dbo.tfFullName
  15. (
  16. @firstName nvarchar(50),
  17. @lastName nvarchar(50),
  18. @middleName nvarchar(50)
  19. )
  20. returns table
  21. as return
  22. select
  23. FullName = @lastName + ' ' + left(@firstName, 1) + '.' + left(@middleName, 1) + '.'
  24. GO
  25.  
  26. select f.FullName
  27. from Students s
  28. cross apply dbo.tfFullName(s.FirstName, s.LastName, s.MiddleName) f
  29. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement