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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 length-1

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2006-11-28 : 02:16:15
Hi,

I have a table called Details in SQL SERVER 2005. The table has a field called Weekdays that stores data in the form saturday,sunday,monday,
I want a select query that will return the values but without the last comma so the result must be
saturday,sunday,monday

How can i do that?
Thanks

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-11-28 : 02:21:45
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx

Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-28 : 02:27:52
SELECT CASE WHEN RIGHT(weekdays, 1) = ',' THEN LEFT(weekdays, len(weekdays) - 1) else weekdays end
from yourtable


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-28 : 02:40:41
Instead of writing query to exclude last comma, while inserting itself take care to insert properly. It will save much of the unnecessary overhead.

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page
   

- Advertisement -