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 2005 Forums
 Transact-SQL (2005)
 Question

Author  Topic 

avijit_mca
Posting Yak Master

109 Posts

Posted - 2009-10-12 : 03:25:24
1. How i will remove space in sql with out using trim function.
2. I have two same constrain with different name on colum called x.
now if i inserted value on colum x then how many time it will checkk constrain.

Regards,
avijit


Regards,
avijit

varunragul
Starting Member

10 Posts

Posted - 2009-10-12 : 06:30:08
1) One of the way without using TRIM
If u know u r output Length then Select CAST('varunragul' as Char(5))

2) 2
Go to Top of Page

avijit_mca
Posting Yak Master

109 Posts

Posted - 2009-10-16 : 07:26:27
Thanks for ur reply but its not working.
declare @x as varchar(50)
set @x=' abc '--2 space
select @x,CAST(@x as Char(3))
out put : a



Regards,
avijit
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2009-10-16 : 07:37:02
You can use REPLACE to remove all spaces (anywhere in the string):

declare @x as varchar(50)
set @x=' abc '--2 space
select @x = REPLACE(@x, ' ', '')
select @x,CAST(@x as Char(1))


Or LTRIM(RTRIM(@x)) to remove leading and trailing spaces only.
Go to Top of Page
   

- Advertisement -