In my code, I am creating a temp table using select * into #tempTable.  Temp table contains the huge number of records and I need to retrieve data from it many times in my code so I created a clustered index on it. But somehow I am not getting data in correct order as per created index.  I know I can do it simply by putting the order by clause, but my question is why I am not getting data in the correct order even if I am forcing the optimizer to use the particular index?  Below is my sample code:  ----------- Sample code ----------------------------  ;with CTE1 as (     select col1         ,col2         ,-- - -- - - from table1      union      select col1         ,col2         ,-- - -- - - from table2         -- few more tables in union --     )     , CTE2 as (     select *         ,RowNumber = RowNumber()              over (order by case                      when @sortOrder = 0                     then case                              when @sortColumn = 'Date'                             then [tdate]......some more dynamic order by conditions..........                          end                     end asc             )     from CTE1     inner join     from TABLE3 on -- some conditions     ) select * from CTE2 into #TempTable;   Then add the clustered index:  create clustered index IX_TempTable_RowNumber on #TempTable (RowNumber asc);  select * from #TempTable with (index (IX_TempTable_RowNumber));  ----------------- End of sample code ---------------------   Even I checked the table scheme and index details using  exec tempdb.dbo.sp_help N'#TempTable';  select * from tempdb.sys.indexes where name = N'IX_TempTable_RowNumber'   And it seems correct to me. What am I missing here?
In order to better understand the SQL Server query processor, I've been thinking about how the ORDER BY clause works, and how SQL Server provides results.  It appears SQL Server will provide results in exactly the same order for any given set of data that remains the same and never, ever changes.  Once you introduce any kind of uncertainty such as developers changing something, the order of results can no longer be expected to be the same.  Simply seeing the results in the same order, each time you press F5 does not guarantee the results you expect.  Try this:  USE TempDB; DROP TABLE TestOrderBy; DROP TABLE TestOrderBy2; CREATE TABLE TestOrderBy (     ID INT NOT NULL CONSTRAINT PK_TestOrderBy PRIMARY KEY CLUSTERED IDENTITY(1,1)     , SomeData varchar(255) ); INSERT INTO TestOrderBy (SomeData) VALUES ('E'); INSERT INTO TestOrderBy (SomeData) VALUES ('D'); INSERT INTO TestOrderBy (SomeData) VALUES ('C'); INSERT INTO TestOrderBy (SomeData) VALUES ('B'); INSERT INTO TestOrderBy (SomeData) VALUES ('A');  CREATE TABLE TestOrderBy2 (     ID INT NOT NULL CONSTRAINT PK_TestOrderBy2 PRIMARY KEY CLUSTERED IDENTITY(1,1)     , SomeData varchar(255) ); INSERT INTO TestOrderBy2 (SomeData) VALUES ('E'); INSERT INTO TestOrderBy2 (SomeData) VALUES ('D'); INSERT INTO TestOrderBy2 (SomeData) VALUES ('C'); INSERT INTO TestOrderBy2 (SomeData) VALUES ('B'); INSERT INTO TestOrderBy2 (SomeData) VALUES ('A');  SELECT SomeData  FROM TestOrderBy UNION ALL SELECT SomeData FROM TestOrderBy2;  CREATE INDEX IX_TestOrderBy_SomeData ON TestOrderBy (SomeData); CREATE INDEX IX_TestOrderBy2_SomeData ON TestOrderBy2 (SomeData);  SELECT SomeData  FROM TestOrderBy UNION ALL SELECT SomeData FROM TestOrderBy2;   The results:    As you see, adding a simple index on the fields selected in the query alters the order of the results.  From here on, I'm adding ORDER BY unless I truly don't care.
If $A\subseteq\mathbb N$ and $\sum\limits_{a\in A}\frac1a$ converges then $A$ has natural density $0$ In this  to a question about a series, a theorem was stated:     If $A= \{a_i \}$ is a set such that $\sum_{i = 1}^{\infty} \frac{1}{a_i}$ converges, then $d(A) = 0$, where $d(A)$ is the  of the set.   My background in number theory is basically zero and all my attempts to prove this have been utterly unseccessful; would anyone please help me, or at least provide me with a hint to prove it? can't find using System.Web.UI.HtmlControls namespace Novel about interstellar war: Both sides win, both sides think they lost I recall reading this novel in the &rsquo;90s; my recollection is that the author was better-known for bad fantasy than for SF (but the SF of his that I&rsquo;d read was better than his fantasy).  The story opened in media res just before a battle was joined; there is a dialogue between the captain of one of the ships and one of his crew. We never see the actual battle; we instead see the conquest of Earth by the aliens - and the conquest of the alien homeworld by Earth.  It is slowly revealed that the two sides contrived a way to both avoid the destruction of actual war, and solve their respective worlds&rsquo; respective problems of overpopulation, infrastructure decay, et multae ceterae. We also see that the solution was that the conquering aliens were secretly selecting Earthmen to rule their homeworld, while the humans were selecting aliens to rule Earth.  About halfway through, there is suddenly a third world that must be &lsquo;conquered&rsquo; and brought into the network. The plot gets complicated after that. How to check if a row exists in MySQL? (i.e. check if an email exists in MySQL) Move all files within subfolders to parent folder Firstly, I'm aware there are tons of similar questions, and I know because I must have tried adapting at least 5 of them, but I'm still here asking because my crappy grasp of CMD (which I actually thought I was getting good at up until this point) is frustrating me with generic, unhelpful errors, and I can't understand what part of the syntax is wrong. This is likely due to the fact that other questions deal with the folder/filename structures of their respective OPs, and when I try to adapt the code to my own folder/file structure it refuses to work. Therefore, I'm here asking for a CMD for loop solution that'll actually work for my own file and folder structure.  I have a parent folder which contains many other folders, in which there are files:  Parent Folder      Subfolder            File1            File2      Subfolder            File1            File2      Subfolder            File1            File2   ...and so on.  I'm wanting to use a CMD for loop in combination with the move command to extract all the files in the subfolders to the parent folder, leaving each subfolder empty.  When giving the CMD for loop please break down what each part of the command is doing, as this'll help make sure I understand the code and hopefully minimise the trouble I have getting it to work for myself. QGIS calculates main soil type of polygons from another polygon layer Novel about a guy who is possessed by the divine essence and the world ends? I read this novel back in the mid-80's but I'm pretty sure it was written in the 70's.  Strange things start to happen around a homeless man - like the laws of chance are changed.  The investigators discover that they can figure out what is going to happen next by interpreting the dreams/vision of the man.  One such dream is of a large body of water that is split into two pieces. Turns out that means that "C" (sea) - the speed of light has been halved.  The homeless man had become the embodiment of the creator essence. The creator was hiding, because it was tired of trying to keep the universe working and from the fight with is adversary - chaos.  At the end of the book, the creator allows the world to be destroyed and recreates it - except that planets are cubes and move in squares.  Yes - it was rather bizarre. Install MySQLdb (for python) as non-compressed egg The install instructions are:  $ python setup.py build $ sudo python setup.py install # or su first   This gives me an .egg file. How do I tell the install to dump the files as a normal, uncompressed library?  Thanks! How do I check whether a file exists without exceptions? Subtracting (erasing) polygons from polygon using ArcGIS for Desktop? How to view all the Symbolic links,Junction points,Hard links in a Folder using dir? The command dir /a displays a list of all the files,folders in a given location. But it displays the type  for Junction Points as well as Symbolic Links to Folders. Is there any command which will differentiate and tell me which of these  are Junction Points and which are Symbolic links as well as which of the files are hard links ? How do I get a slanted \sum symbol? I want to use a slanted \sum symbol denoting a different meaning from summation. How do I get a slanted \sum symbol? I read this book series in middle school. I believe that it would be classified as young adult fiction/fantasy. A girl has magical powers, and with her growing powers comes runes/tattoos in her arms. This is shown on every book cover. I know that one cover is blue. This one shows the girl in a black tank top and black pants. One is a yellow cover, with her in a dress (I think).  The girl has a friend/mentor, who she develops feelings for. The girl is the key to stopping a war between multiple factions/people. Each side is trying to use her to their advantage. I think the series was written in the early 2000s. There are a few examples of pairs of words ending with -ee/-er like employee and employer or advisee and adviser. What I was curious about is if there was any rule that would describe the relationship of the objects in a pair like this and situations when it's appropriate to create a counterpart for a given word.   I'll give you an example. It's relatively common in the computer programming world to see the word dragee, which describes an object that is being dragged with a mouse. I understand that this is a relatively new word and could not be found in any dictionary (I've tried). Is that acceptable to make up words like this one or is it just bad English? I am thinking of building a model predicting a ratio $a/b$, where $a \le b$ and $a &gt; 0$ and $b &gt; 0$. So, the ratio would be between $0$ and $1$.  I could use linear regression, although it doesn't naturally limit to 0..1.  I have no reason to believe the relationship is linear, but of course it is often used anyway, as a simple first model.  I could use a logistic regression, although it is normally used to predict the probability of a two-state outcome, not to predict a continuous value from the range 0..1.  Knowing nothing more, would you use linear regression, logistic regression, or hidden option c? I have two tables in my database:  NEWS table with columns:   id - the news id  user - the user id of the author)   USERS table with columns:   id - the user id   I want to execute this SQL:   SELECT * FROM news JOIN users ON news.user = user.id    When I get the results in PHP I would like to get associative array and get column names by $row['column-name']. How do I get the news ID and the user ID, having the same column name? On Windows 7 can one make UAC on an admin account prompt for the password, just like a limited account? I am one of the very few who likes the security of UAC and so I have the UAC set to "Always Notify" on my Admin account. But I would be even happier if the system would prompt me for a password, when notifying me.  I can get what I want by adding a second non-admin user and using that account.  But somehow it seems wasteful to have two accounts set up when I will always use the non-admin account day-to-day.  So I am wondering if there is any setting that would cause an Admin account to behave password-prompting-wise as a standard account? href to an image label - how to jump to the image instead of the caption below the image? Upgrading from Yosemite to El Capitan, but not Sierra We have an older iMac (Model A1311, Mid 2011). It has been running Yosemite. We have run into some of the WIFI issues associated with Yosemite.   Is it possible to upgrade to El Capitan but not Sierra?   El Cap has been out longer. Its my wife's computer, its older, and I really don't want to be debugging Sierra until a few  more "dot" releases come out. How do I protect Python code from being read by users?