Sql 如何在sp中追加查询?

Sql 如何在sp中追加查询?,sql,Sql,假设firstname、*lastname*、city有3个文本框。 基于文本框中的条目,它被添加到where子句中。 这是我的问题 select col1,col2 from table1 where 假设将name放入texfirstname,那么查询如下 select col1,col2 from table1 where firstname = txtfirstname.Text select col1,col2 from table1 where firstname = txtfi

假设firstname、*lastname*、city有3个文本框。 基于文本框中的条目,它被添加到where子句中。 这是我的问题

select col1,col2 from table1 where
假设将name放入texfirstname,那么查询如下

select col1,col2 from table1 where firstname = txtfirstname.Text
select col1,col2 from table1 where firstname = txtfirstname.Text and lastname = txtlastname.Text
若用户在textlastname中输入lastname,那个么查询将如下

select col1,col2 from table1 where firstname = txtfirstname.Text
select col1,col2 from table1 where firstname = txtfirstname.Text and lastname = txtlastname.Text
我将根据用户在文本框中输入的内容添加到主查询中

如果用户填写文本框,如何在存储过程中执行此操作

Create Procedure spTest
(
  @Value nVarChar(10)
)
As
Begin
   Select col1,col2 from table1 where firstname = @Value 
End