create table tb(a int,b int,c int) insert into tb select 1,1,1 insert into tb select 2,2,2 insert into tb select 3,3,3 insert into tb select 4,4,4create proc proc_tb @a int=-1 as begin if @a=-1 select * from tb else select * from tb where a=@a endexec proc_tb a b c 1 1 1 2 2 2 3 3 3 4 4 4 exec proc_tb 1 a b c 1 1 1
select * from T where col= isnull不好用
不用存储过程行不默认值给什么啊? select * from T where col= 默认值?
string sql="select * from a"; if(txtid.text !="") { sql += " where id='"+txtid.text+"'"; } 这意思?
insert into tb select 1,1,1
insert into tb select 2,2,2
insert into tb select 3,3,3
insert into tb select 4,4,4create proc proc_tb
@a int=-1
as
begin
if @a=-1
select * from tb
else
select * from tb where a=@a
endexec proc_tb
a b c
1 1 1
2 2 2
3 3 3
4 4 4
exec proc_tb 1
a b c
1 1 1
select * from T where col= 默认值?
if(txtid.text !="")
{
sql += " where id='"+txtid.text+"'";
}
这意思?
{
string sql="select * from a";
查询+绑定gridview
} protected void BtnSelect_Click(object sender, ImageClickEventArgs e)
{
string sql="select * from a";
if(dropdownlist.SelectedItem.Text != "全部")
sql+=" where 字段='"+dropdownlist.SelectedItem.Text+"'";
}
where a=a --a为列名 我想将列名作为默认值怎么办?
select ....
else
select ....