Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is INLIST() in SQL Server optimized?
Message
From
18/05/2008 06:26:46
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:
01317946
Views:
8
>>>
>>>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
>
>Cetin,
>
>Thank you very much for the example of creating temporary table in SQL Server.
>
>But as I look at your example, I am wondering what is better/faster/more efficient: 1. Creating a temp table and, say, inserting 20 or 50 rows into the temp table (which means calling SQLExec so many times. Or 2. Creating a string of values to be used in the IN clause of one SQL Select against the "myTable" without temp table. What is your (and others) feeling on that?

It can be a single SQLexec call. Speed depends. If all would be done in a single call then building the IN list create a shorter command to send over the wire. If values would be send at different times thenthe table approach might be better.
One or the other SQL server process it fast.
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