It's the top 5 of the subquery. There are 5 rows that should be returned by the subquery but I need them in a random order. I can order by a specific column and the subquery will return 5 rows but when ordering by NEWID I get a different number of rows each time from the subquery.
As I understand it the ORDER BY in the subquery should just return the same number of rows but in a different order. Is that correct?
Thanks,...
User Profile
Collapse
-
ORDER BY NEWID() Problem
I have the follwoing query:
My problem is that the Top(5) part of the query is being ignored and instead a random number of rows is returned. Somtimes no rows, sometimes 5, sometimes 10. If I change the Order by NEWID() to Order by Column1 then the Query works...Code:SELECT Column1, Column2 FROM Table1 WHERE Table1.Column1 IN ( SELECT TOP (5) Column1 FROM Table2 ORDER BY NEWID() )
-
Sorry if my explanation was a bit vague.
@jerry Winston you are correct that rows can have a correlated "FK" row with the FK equal to that of the "PK" row inserted before. The scenario isn't applicable to all rows. Basically each row represents a module in my application and I need there to be a relationship between some modules (parent module and child module)
@Ck this was what I was looking for (whether...Leave a comment:
-
Basically I want to insert two rows into the same table using one SQL call.
The second row to be inserted needs to use the newly created ID (auto generated primary key) from the first row. So I know that I can get the newly created ID from the first call using @@IDENTITY but can I use this in the second Insert statement? If I do 2 completly seperate calls to the database then it's fine but I want to do just one call.
Hope...Leave a comment:
-
Multiple Inserts
Hello,
I want to do two sql INSERTS into the same table (table holds pk and fk rows) but I need the second insert to use the new Identity from the first INSERT. Something like:
However this doesn't work! Is this...Code:INSERT INTO [table] SELECT [Cols] FROM [Table] Where [blah];SELECT NewUDValue AS @@IDENTITY; UNION ALL SELECT [colName = NewUDValue, more cols] FROM [Tablle] Where [Blah]
-
MVC Form URL Routing
Hi All,
I'm a bit new to MVC so sorry if this is a stupid question and I'm not seeing the obvious answer :)
I am using a form with the method set to GET. When I submit the form the URL appears as:
MySite/Search/?SearchTerm={Bl ah}
However I want
MySite/Search/Blah/
I have tried to set this up in the Global.asax like so:
...Code:routes.MapRoute(
-
Series 40 Mp3
Hi All,
I'm trying to deliver Mp3 files to through the browser to the handset. This works on every handset except a selection of Nokia series 40 handsets.
For example when I try to download the file using the Nokia 6300, the phone spends about 2 mins loading then I get the message link not available. The exact same link (direct to mp3) works on a Nokia N95.
Would anyone know if there is something special... -
ok found a solution that seems to do the job. If the product does not exist I execute the following code else I return the View as normal. This should work providing the action 'MissingProduct ' returns a View.
...Code:GenericController controller = new GenericController { ControllerContext = ControllerContext }; controller.RouteData.Values["controller"] = "Generic"; controller.RouteData.Values["action"]Last edited by Frinavale; Jul 21 '10, 07:39 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.Leave a comment:
-
MVC Server.Transfer
Hi All,
I'm a newbie to MVC and have run into a situation where for example the user goes to url
MySite/Category/?id=10
If there are no products for categoryid 10 then I want to server.transfer to a generic product missing error page (keeping the URL the same). From what I understand about MVC I'm not able to just server.transfer so how would I do this?
Thanks in advance,
Steve -
ok ignore that...
XMLDocument.Cre ateTextNode("So meText");
XMLDocument.Cre ateElement("br" );
XMLDocument.Cre ateTextNode("So meMoreText");
and append them in that order worked.Leave a comment:
-
XML and ASP.Net
I have to create XML on the fly and the inner text of an element needs to have a <br/> in it like :
<ElementName>So meText <br/> Some more text </ElementName>
if I try:
ElementName.Inn erText = SomeText <br/> Some more text ;
the < and > get encoded and it doesn't work.
I have tried Creating a br node using the createnode method but this puts the <br/>... -
Was a namespace problem. I moved the code from one project to another and didn't set the namespace once it was moved. DOH!!!
CheersLeave a comment:
-
Class Library can't be found!
I have a web Application and have created a seperate class library project.
I am trying to use the Class Library by referencing it in the Web Application. I am doing this by right clicking the web application and clicking 'Add Reference...'. I then browse to my Class library and click ok. This gets added to a Bin folder in my web application.
The problem is I can't actually get any of the objects that are in the Clas... -
asp.net httpModule
I have a HTTPModule which i want to be called every time the page loads but it seems that it will load the first time I browse to the site and then not load again even when I refresh or click a link to another page. If I edit and save the web.Config then the httpModule will hapilly load, but again only once.
Strangly it was working perfectly fine a while ago. I've changed something but I'm not sure what.
Any ideas... -
So is there any general rule of thumb to dictate when I should choose to use the Singleton design pattern over the Static class? And are there any performance differences between the two options?Leave a comment:
-
I think your best bet is to make the link an asp.net control rather than a standard HTML link. You can then databind the Visible attribute to say something like:
<%# Visible='<%# Eval("Website") == "" %>
That should set the visibility of the link to true or false.
SteveLeave a comment:
-
Static Class or Singleton
Static and Singleton classes seem to provide very similar functionality from what I can see. Can someone tell me what the differences are and in what situation each would be better suited?
Steve -
UpdatePanel Animation
I have a list of buttons with an update panel underneath. When you click one of the buttons the update panel will refresh with different content. I have this working fine but I want to make it look nice with some jQuery animation so when you click the button the update panel refreshes and the content slides down.
Any javascript that I attach to the buttons seems to fire before the update panel is refreshed.
What is... -
Thanks for your reply.
I'm generating the LinkButton dynamically in a click event of a different Button. Therefore both Page_Load and Page_Init events have already fired by this point. That's the reason why I didn't use either of these events. I'm not able to generate the LinkButtons before this as I need input from the Click Event (CommandArgumen t in case your wondering) before creating the new controls.
Is it bad practice...Leave a comment:
-
found a solution although not sure if it's the best one...
As I create the dynamic controls I also add them to an array. Then when I post back and refresh the update panel I have a method that goes through the array and puts the controls back in.
I'm sure there is a better way to do this but I've spent way too much time googling it!!
Any suggestions of a better way are welcome :)Leave a comment:
No activity results to display
Show More
Leave a comment: