数据为空........??什么意思
猜一个create proc Test @a=null
as
select * from T where col=isnull(@a,col)
go
exec test--可指定也可不指定..

解决方案 »

  1.   

    猜一个create proc Test @a int=null--赋默认值
    as
    select * from T where col=isnull(@a,col)
    go
    exec test--可指定也可不指定..
      

  2.   

    create table tb(id int,name varchar(10))
    insert into tb select 1,'a'
    insert into tb select 2,null
    insert into tb select 3,'c'
    insert into tb select 5,'d'
    insert into tb select 5,'d'
    insert into tb select 7,'e'
    insert into tb select 7,'e'
    insert into tb select 8,'f'
    insert into tb select 9,'g'create proc pro_tb
    as
    begin
    if exists(select 1 from tb where name is null) 
    raiserror   50005   N'错误,过程终止'
    endexec pro_tb消息 50005,级别 16,状态 1,过程 pro_tb,第 5 行
    错误,过程终止
      

  3.   

    不好意思了,我表达不清。 我再补充我的问题吧。例如:
    我的web页面上有两个TextBox控件,一个boutton控件.当我单击boutton控件时,就可以把TextBox控件的内容保存到数据库里面。 如果有一个TextBox控件的内容为空,则不能保存. 如何用存储过程实现这个功能.
      

  4.   

    你直接在TEXTBOX控件退出的时候来判断不就行了吗,何必用存储过程来实现呢
      

  5.   

    我的web页面上有两个TextBox控件,一个boutton控件.当我单击boutton控件时,就可以把TextBox控件的内容保存到数据库里面。   如果有一个TextBox控件的内容为空,则不能保存.   如何用存储过程实现这个功能. -----------------
    直接在页面上实现不是更简单?
      

  6.   

    不好意思了,我表达不清。   我再补充我的问题吧。例如: 
    我的web页面上有两个TextBox控件,一个boutton控件.当我单击boutton控件时,就可以把TextBox控件的内容保存到数据库里面。   如果有一个TextBox控件的内容为空,则不能保存.   如何用存储过程实现这个功能. ---create table tb(id int,name varchar(10))
    gocreate proc pro_tb
    @col varchar(8000)
    as
    begin
    if isnull(@col,'') = '' 
    begin
        raiserror   50005   N'错误(企图插入一个空值到name列),过程终止'
        return
        end
    else
       insert into tb select 1,@colend
    goexec pro_tb 'adfadsf'
    select * from tb
    /*(所影响的行数为 1 行)id          name       
    ----------- ---------- 
    1           adfadsf(所影响的行数为 1 行)
    */
    exec pro_tb Null
    select * from tb
    /*
    服务器: 消息 50005,级别 16,状态 1,过程 pro_tb,行 10
    错误(企图插入一个空值到name列),过程终止
    id          name       
    ----------- ---------- 
    1           adfadsf(所影响的行数为 1 行)*/
    drop proc pro_tb
    drop table tb