Friday, September 19, 2008

Disable or readonly the checkbox using javascipt

For disable or readonly the checkbox using javascipt use the disable property of checkbox.

document.getElementById("ChkBoxName").disabled =false;

And for the Enable the checkbox using javascript

document.getElementById("ChkBoxName").disabled =true;

Check the column value if value is in string format with coma separated using Sql

If column value is in 1,2,34,23,44,444,12,23,... format than how can check the value using like operator in Sql. means if the coma separated value is in column in any table then how can check the value using like operator in Sql.

solution:
select * from s
where
sid like '44,%' or sid like '%,44,%'
or sid like '%,44' or sid='44'

where sid is column name
this will only return the 44

Return Multi Row value in a single column with comma seprated

Return Multi Row value in a single column with comma seprated using sql
I want Return output like 1,2,3,4,5 using sql.
There is one table in which has column
id name
1 Dilip
2 Dinesh
3 Varun
4 Dhanpat
5 Renuka

solution:
declare @a varchar(500)
set @a = ' '
select @a = @a + cast(id as varchar(20)) + ',' from tablename
if len(@a)>1
set @a= left(@a,len(@a)-1)
select case @a when '' then '0' else @a end as id


Use case , becaue may be there is no any value in this table so it will retun o