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 |
|
drey
Starting Member
10 Posts |
Posted - 2004-09-01 : 10:47:49
|
| I am trying to read a table:select * from table1where letter in (@parameter) @parameter is a list like 'a', 'b', 'c'the select statement is in a dataadapter. when i try to fill a dataset I get nothing. but if i remove the parameter and had code the list in the select statement, I get the expeted rows in my dataset.I tried set the list with the outter ' and without it.thank you |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-01 : 10:54:15
|
| thats becasue it doesn't work this way.if you're building a statement in .net build it without parameters:string stmt = "select * from table1 where letter in (" + parameters + ")"sqlCommand.Text = stmtothwerwise u need to do it via dynamic sql.http://www.sqlteam.com/item.asp?ItemID=4619Go with the flow & have fun! Else fight the flow :) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-01 : 11:02:31
|
| even better... :)) because IN is so popular when you're starting sql. i used it a lot in my very early days... didn't you brett?Go with the flow & have fun! Else fight the flow :) |
 |
|
|
drey
Starting Member
10 Posts |
Posted - 2004-09-01 : 11:22:44
|
| to spirit1fmi only...why do you say "IN" is popular for beginners?what is better? |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-01 : 12:59:35
|
| well of course it all depends on the situation.using exists is usually faster. and a lot of things can be solved with joins instead of IN(...). joins are also faster.but that's only my opinion.and i can't remember when was the last time i used an IN(..) in an app.Go with the flow & have fun! Else fight the flow :) |
 |
|
|
|
|
|