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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-09-25 : 08:14:51
|
| philipl writes "hi,I saw your answer to passing arrays to store procedures from a while back. The next question is, can you write SQL code to use elements pass in with the array in your select statement. For exmaple?Create procedure sp_ParseArray( @Array varchar(1000),select * from mytable where field1 = Array[1],field2 = Array[2],.....fieldn = array[N]endSo really we are building the select statement at run time. If we can't do this, is there a workaround?thx" |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-09-25 : 10:00:32
|
| why do you have an array? Why not just multiple parameters, one for each field?if you want something generic that works with every table, use the SELECT statement. don't reinvent the wheel. you can create VIEWS if you like, so users aren't hitting tables directly.- Jeff |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-09-25 : 10:04:32
|
| Like Jeff said...seems like you already know what you want...why bother doing this?Also what does your "array" (which btw is not available in sql server) contain?Column Name and value? (notice it's not field name)[remorse]There's always dynamic sql[/remorse]Brett8-)SELECT @@POST FROM Brain ORDER BY NewId()That's correct! It's an AlphaNumeric! |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-09-25 : 11:13:02
|
| You need to parse your @array into a table. Then join to your heart's content.Jay White{0} |
 |
|
|
|
|
|