Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ktimov1
Starting Member
6 Posts |
Posted - 2010-07-29 : 10:29:44
|
Hello,I need help creating a stored procedure which will output a count based on user inputs from VB or C# app.For example: user will input a field name and a value from textboxes and then the stored procedure will run:SELECT COUNT(*) FROM table WHERE txtField = txtValueFinally the count result will be posted to them.Any ideas on how I can accomplish this |
|
|
Devart
Posting Yak Master
102 Posts |
Posted - 2010-07-29 : 12:20:30
|
| Hello,You can try this:create procedure <your_procedure_name> (@table varchar(<your_size>),@field_name varchar(<your_size>),@field_value varchar(<your_size>))asset nocount ondeclare @sql varchar(8000)set @sql='SELECT COUNT(*) FROM '+@table+' WHERE '+@field_name+' = '+char(39)+@field_value+char(39)exec (@sql)Best regards,Devart Team |
 |
|
|
|
|
|