declare @cust_id int, 
        @sqlstr varchar (4000),
        @sqlwhere varchar (4000)set @sqlstr='select * from table '
set @sqlwhere=' where cust_id = ' +cast(@cust_id as varchar)exec (@sqlstr+@sqlwhere)

解决方案 »

  1.   

    declare @cust_id int, 
            @sqlstr varchar (4000),
            @sqlwhere varchar (4000)set @sqlstr='select * from table '
    set @sqlwhere=' where cust_id =' +cast(@cust_id as varchar(20)) 
    exec (@sqlstr+@sqlwhere)
      

  2.   

    --少东西,还没等号
    declare @cust_id int, 
            @sqlstr varchar (4000),
            @sqlwhere varchar (4000)set @sqlstr='select * from table1 '
    set @sqlwhere=' where cust_id=' +cast(@cust_id as varchar) --( 这句该怎么写呢?字段cust_id 是数值型)exec (@sqlstr+@sqlwhere)