vongrunt,
Shouldn't that be "A.OrderCount>=B.OrderCount" rather than "A.OrderCount<=B.OrderCount"? (not trying to flame - just clarifying because I want to use a statement like that)
A very elegant solution - a gold start for you, Sir (or Madam, as the case may be - please pardon any...
If you're only storing date values in those fields, actually create the fields as datetime data types. Then you can sort them reliably and just output the converted format (though the conversion codes 102 and 120 should be sorting them correctly since they return the data in yyyymmdd order).
There are two different sets of SQL statement types you can use for each of these that would be faster than looping through each of the records in the recordset individually. They are the "insert into... select..." and "update... from..." statements.
The first type, "insert into... select..."...
vongrunt,
Can you post an example of how you would do that? I've been tasked with something similar in the past and never found a single statement that could do it. I'd love to find a solution that didn't require cursors or some other kind of looping (which is what I ended up implementing in a...
Is each insert a separate statement? That shouldn't be happening if they are all being inserted by a single statement because it is one transaction and none of the new records should be committed in the database if the transaction did not complete. You can ensure that happens by putting the...
Are you actually inserting new rows into a table or updating existing rows? In your example you're adding the values in Field3 and Field4 of Table1, which suggests you're working with an existing row, but later you say you need to "insert calculated values" into Table1.
I hate to speak in absolutes, but I think it's safe to do so here: There's no way to do that with a single SQL statement.
That being said, you can "simulate" a single SQL statement (to your code, at least) by packaging the necessary steps into a stored procedure and then executing that stored...
From the looks of things what you really want to do is create a user defined function. You can create a UDF like this:
CREATE function dbo.getOverallScore (@emp_id int) returns int
as begin
declare @Score int
select @Score = Avg(SingleScore)
from MyScoreData (nolock)
return @Score
end
Unfortunatey the stored proc won't tell you which is the offending column. There is an easy way to figure out what is doing it though. Just copy the code from the stored procedure into Query Analyzer and execute the SQL directly (you may have to declare and explicitly set variables if you had...
If all you want to do is let the users come to the old URL and hit the new location it would be better to just create a virtual directory on the web server with the old folder name that actually points to the new folder. That way you don't have to worry about creating files to redirect the user...
I can't find the specifics of the API to be sure, but I'm betting the call is probably failing because the user is already logged on to that machine (since by the code you are logging them in to the local machine).
I'm a little unclear on what you mean by an optimum number of indexes. Are you referring to the number of indexes on a given table, or indexes specified within the select statement itself?
If what you are asking is what is the optimum number of indexes to put onto a table then the answer is...
Assuming this code is in a stored procedure, you would want to drop the temp table as soon as you are done working with the data. If all you are doing is returning the data then you would drop the table immediately after the exec statement. If you don't drop it explicitly the table would drop...
I'm not sure about why the ORDER BY is setting the data type, but I have a suggestion on how to get around it. If you take your query and load the results into a temporary table you can then generate and execute dynamic SQL to return the data ordered as you like. Basically it would be something...
I'm not sure why you would want the pause either, but you could loop through fetching 10 records at a time based on the ID. Assuming you have an integer variable "intStartingRow", a database connection "objConn", a recordset object "objRS", and a string variable "strSQL" you could do it like...
I haven't tried this so I'm not sure if it would work, but you could try setting up an ODBC datasource that connects to the database using windows authentication, then specify that DSN with the UserID and Password. That might let you specify a different UserID than the web service. Just try...
We're only using the money data type on fields that actually hold monetary data and we're not doing any complex calculations with them so the precision is sufficient for what we have it used for, but that's definitely something good to keep in mind for future development.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.