Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is INLIST() in SQL Server optimized?
Message
From
16/05/2008 16:14:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01316947
Message ID:
01317736
Views:
8
>>
>>1) Do not use inlist() bu in ().
>>2) Unlike VFP you can send very long lists.
>>3) As list size increases it gets slower (SQL server needs to consume a larger input)
>>4) An alternative is to create a temp table on the same connection and insert values in that table then use a join (or in (select ... )). This approach works better if you are using the same query for both VFP and SQL.
>>Cetin
>
>Thank you, Cetin.
>
>Although I don't understand how to do item 4) in your list. How do you create a temp table in SQL Server without a stored procedure?
SQLExec(m.lnHandle,'create table #myIdList (myId i)')
SQLExec(m.lnHandle,'insert into #myIdList values (1)')
SQLExec(m.lnHandle,'insert into #myIdList values (2)')
SQLExec(m.lnHandle,'insert into #myIdList values (3)')
SQLExec(m.lnHandle,;
 'select myTable.* from myTable inner join #myIdList ids on ids.myID = myTable.pkid', 'result')
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform