SQL Server :: Combine Two Self Referencing Queries In A Function?
Feb 23, 2011
I have a menu table which has a (mostly) unlimited number of levels/tiers:
[Code]....
I also have a working function which will give the up and down tiers based on a given MainMenuId:
[Code]....
My question is, is there a better way to do this such as combining the two querries? Every attempt I have made results in a "The Statement terminated. The maximum recursion 100 has been exhausted before statement completion"
the save as works fine. but the alert wont popup in the else case. I tried RegisterStartupScript. I tried many options. But it seems that the response.end is stops the clientscript from happening.
I am writing in c# asp.net (ajax enabled website, but not in use), visual studio 2005.
I would like to use the IEnumerable function Intersect() to combine a few list and get the similar integers from each list. The problem I'm faced with is that I don't know how many list I will need to compare.
Here is an example:
A{1,2,3,4} B{1,2,3} C{1,2}
results = A.Intersect(B).Intersect(C)
This works great, but the next time around I may have a D{1,2} next time I come across the function.
I'd like to use the Intersect method, but I'm open to new ideas as well.
have a complex sql stored procedure which involves several unions.The unions also involveat from views. When the data is returned, it might look like the following.
ProductId Name Amount Buyer Date YearsAsCustomer 1 Jones 234.44 Nichols 1 Jones 3/12/2011 3 2 Melon 333.00 Tripol 2 Melon 3/23/2011 4
This is just a simple example, but notice how the records with the same product Id can be combined?Because one record has some of the data I need and the other record has different data. So essentiallythey should just be in one record together. So the output should look like this:
ProductId Name Amount Buyer Date YearsAsCustomer 1 Jones 234.44 Nichols 3/12/2011 3 2 Melon 333.00 Tripol 3/23/2011 4
How can I combine these records together? In the stored procedure the query is build in a parameter stringnamed @SQL, and then the query is executed by using the EXEC command:EXEC sp_executesql @SQL.Is their anway I can combine all of the outputted records into one record. Where the records I want to combine have the same ProductId (As in the example I illustrated above?)
I have a web site that is hosted by Network Solutions. The hosting package I have includes support for ASP. I can place a simple aspx page on my web site and point to it with my browser and it appears to execute. What I'd like to do is reference a text file (for parsing) that is in the same folder as the aspx file. I have no idea what the absolute path is to the folder. How can I reference the file for reading if I don't know the absolute path?
I have a select statement. I need to get a field value from the first statement. GOAL: Below is what I am trying to accomplish - the code below is not correct - Please modify the statement with the correct SQL Syntax. I want to query a table and based on the results I want to set the "If THE Else"statement to query then table with diffent inner joins.
SELECT * FROM CONTENTITEM CI INNER JOIN CONTENTCATEGORY CC ON CI.CATEGORYID = CC.CATEGORYID IF CI.FORMTYPE = 200 OR 300 SELECT * FROM CONTENTITEM CI INNER JOIN CONTENTCATEGORY CC ON CI.CATEGORYID = CC.CATEGORYID INNER JOIN CONTENTFORMFIELD CF ON CF.ITEMID = CI.ITEMID WHERE CI.ITEMID = @ITEMID ELSE SELECT * FROM CONTENTITEM CI INNER JOIN CONTENTCATEGORY CC ON CI.CATEGORYID = CC.CATEGORYID WHERE CI.ITEMID = @ITEMID
I am wanting to produce and SQL stored procedure that will combine a the CompanyID with the CompanyName I order to display this in a drop down list/This is what i have so far....
Select CompanyID + ' - ' + CompanyName As DisplayName, CompanyID From Company
The error I get says:
"Conversion failed when converting the nvarchar value 'testcompany' to data type smallint."
Now Im presuming this is caused by the CompanyID being an int and the CompanyName being a string.
I want to find the sum of each tables fileld. how can do this. i tried the following.but could nt get the correct sum. "SELECT SUM(gb) FROM data20 union all SELECT SUM(gb) FROM data10 union all SELECT SUM(gb) FROM data5 union all SELECT SUM(gb) FROM data6"
I am using ajax control toolkits and ajax extentions in my projects. and as you know it overhead some libraries to page. How can I combine them into 1 js file to reduce requests to server ???
I am using JQuery for all of my client side validation and Asp.net validator controls for all of my server side validation. I am using an errorlabelcontainer to store the client side validations in a summary at the top of the page, which is the requirement. All works well. My problem is, I want to display the server side asp.net errors in the same errorlabelcontainer OR display all of the client side errors in the validation summary. Either way, Both errors need to be in the same place/div. Any ideas on how to do this? I thought of maybe using the asp.net validation summary as the errorcontainer in JQuery, but I cannot find the summary. This is what I have right now.
how to run multiple queries on a single button click. Actually I want whatever a user write in text box and click the button the text would get inserted in table category and also a table name project should get updated. I am using Sql server 2005 and c#
In my stored procedure there are 8 queries for 8 tables.Each query has joins and sub queries. I am passing parameters & stored procedure name from front end(designed in asp.net 3.5) can we execute that 8 queries at the same time i.e. parallel execution so that I can minimize stored procedure execution time?
Alright, we have two database servers, one is owned by us, one owned by a partner. Our partners have been having issues lately that have been causing us numerous sql timeout errors, which takes down our whole system. We'd prefer to limit the time those queries can take to say 20 seconds max, otherwise quit trying and throw the error (which we can catch with a try/catch block). Couple of questions: Is there a way to set a particular db/connection string to timeout after X seconds? Is this the best way to quarantine that other system? or are there better ways to go about this?