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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 CREATE VIEW - last letter is 's'

Author  Topic 

cathymomo
Starting Member

10 Posts

Posted - 2009-03-04 : 09:59:49
Hi, I have to create a view where the users last name ends with a 's' and I am just wondering if this is correct as I cannot test it from where I am now. Thanks.

CREATE VIEW Users_View1 AS
SELECT UserNo, UserFirstName, UserLastName, UserPhone, UserEmail, UserOrgNo
FROM Users
WHERE RIGHT(RTRIM(UserLastName,1) = 's')

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-04 : 10:02:44
it should be

CREATE VIEW Users_View1 AS
SELECT UserNo, UserFirstName, UserLastName, UserPhone, UserEmail, UserOrgNo
FROM Users
WHERE RIGHT(RTRIM(UserLastName) ,1)='s'
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-03-05 : 01:58:23
or

WHERE RTRIM(UserLastName) like '%s'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sumitbatra1981
Starting Member

17 Posts

Posted - 2009-03-05 : 02:06:34
CREATE VIEW Users_View1 AS
SELECT UserNo, UserFirstName, UserLastName, UserPhone, UserEmail, UserOrgNo
FROM Users
WHERE UserLastName like '%s'


Regards,
Sumit Batra
Software Engineer
Go to Top of Page
   

- Advertisement -