Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trim function in a view 2

Status
Not open for further replies.

levinll

Programmer
Oct 29, 2001
65
US
Is it possible to have the Trim function in a view ? I'd like to remove all leading and trailing spaces in a field prior to it being transferred. I can't use a stored procedure because I'm having the data read directly into an Excel Template using Microsoft Query.

Thanks !
 
Yes. Just in your view definition use the Ltrim and Rtrim for each column you want trimmed.

Hope this helps.
 
Hi

Yes you can but you have to use "AS" otherwise sql server will complain about missing column names.

eg:

create view books
as
select book_id, ltrim(rtrim(book_name)) AS book_name, author
from books

Hope this helps

John

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top