Hello everyone,
I would really appreciate if you would take a look at this piece of code:
<?php
if(isset($_POST['add'])) {
$self = $_SERVER['PHP_SELF']; //the $self variable equals this file
$ipaddress = ("$_SERVER[REMOTE_ADDR]"); //the $ipaddress var equals users IP
//connect
$connect = mysql_connect($host,$username,$password) or di...
Hi,
I have a java web application that selects one column from table (with 6 million rows) and it takes a lot of CPU time. This select (SELECT id FROM mytable WHERE filename = 'unique_filename') takes significantly less time when executed in query browser.
What can cause this?
Where should I start to look for bottlenecks?
Database i...
i am writing a macro to convert the zeros in the access table to "0000"
Zero is text data type so i cast it to int in the if condition to update the records which is only zeros and preventing it in updating records which are non zeros
but now all the records are getting updated ..if clause is calling all the time even there is a value...
(SQL 2005)
Is it possible for a raiserror to terminate a stored proc.
For example, in a large system we've got a value that wasn't expected being entered into a specific column. In an update trigger if you write:
if exists (select * from inserted where testcol = 7)
begin
raiseerror('My Custom Error', 16, 1)
end
the update informati...
Does aliasing tables names in large queries have noticeable impact on performance?
Aliasing:
...
...
FROM table_1 T1
...
...
...
Is it significantly different for the various DB systems out there?
...
Q: How do I make MySQL also show every users rating and then sort the results using ratings, desc?
This is all used for a gaming ladder. weblGames has the result of every reported game and has info about who won/lost, and what the winner/losers rating became (winner_elo & loser_elo).
Here is a partial screenshot of the table: http://w...
Possible Duplicate:
Hidden Features of SQL Server
I believe that this question has incorrectly been closed as an exact duplicate. 19 people have this question favorited so I do not believe this is an incorrect assumption. In the question, I am not asking about hidden features as in the other question, I'm ask about features/comm...
Here is the situation:
I have a database of 'tickets', and we track changes to the tickets each time they are saved. I am specifically looking at status changes, which track with the following format:
STATUS:{FROM}:{TO}
with {FROM} and {TO} changing to the respective statuses. What I need to do is generate numbers by weeks of the amou...
I have to produce an ad hock report on the number of transactions made with different credit card types. For the purposes of the report it is fine to assume that all credit cards that start with a 4 are VISA cards and that those that start with a 5 are MasterCard.
This query works well for the above distinctions:
select card_type =
...
The question is to get table column data and use it as a value list for IN function;
For this example I created 2 tables: movies and genres
Table "movies" contains 3 columns: id, name and genre.
Table "genres" contains 2 columns: id and name.
+- movies-+
| |- movie_id - int(11) - AUTO_INCREMENT - PRIMARY
| |- movie_nam...
I have a Function called dbo.GetFoo(). I also have a unit-testing Stored Procedure called AssertEqual (which takes @TargetValue sql_variant, @ExpectedValue sql_variant, and @Message varchar)
I want to call GetFoo() and check to see if it's returning the right value 'X'. My T-SQL statement is:
exec AssertEqual dbo.GetObjectType(), 'S', ...
I currently have a table(/grid) of data that I can page, filter and sort. On the table I also have a built in checkbox column. Paging, filtering and sorting right now happen within the SQL query. What I want to be able to do is sort by the clicked items in my checkbox column. This would bring all items that are checked to the front o...
Are the two statements below equivalent?
SELECT [...]
FROM [...]
WHERE some_col in (1,2,3,4,5) AND some_other_expr
and
SELECT [...]
FROM [...]
WHERE some_col in (1,2,3) or some_col in (4,5) AND some_other_expr
Is there some sort of truth table I could use to verify this? Thanks.
...
I have a few views and I want to insert some data into them. I've heard you need to "be careful when doing this", and you need to "setup the view to make the insert work correctly". What do I need to look for, and what if anything do I need to do to my view to allow insertions into it?
Is better to insert into the underlying tables ev...
i have budgets table with emptype_id and calendar_id actual_head, estimated_head
when i do Budgets.sum(:actual_head ,:group=>"emptype_id,calendar_id") i do not get the result grouped by the above two columns but only by the emptype_id
however when i check the log the sql query is right
"SELECT sum(budgets.actual_head) AS sum_ac...
This is ADO in classic ASP.
I have a stored procedure with a parameter @IsNew of type int.
I can call it via SQL:
EXEC [dbo].[SearchVehicles]
@WebsiteName = N'AMSVans',
@SortOrder = N'Year DESC,Status ASC',
@Statuses = N'Unsold',
@IsNew = 1
And the return sets are exactly as expected.
However, when I attempt to use it in my ...
I'm trying to run multiple ddl statements within one Execute Immediate statement.
i thought this would be pretty straight forward but it seems i'm mistaken.
The idea is this:
declare v_cnt number;
begin
select count(*) into v_cnt from all_tables where table_name='TABLE1' and owner = 'AMS';
if v_cnt = 0 then
execute immediate 'C...
I learned a trick a while back from a DBA friend to speed up certain SQL queries. I remember him mentioning that it had something to do with how SQL Server compiles the query, and that the query path is forced to use the indexed value.
Here is my original query (takes 20 seconds):
select Part.Id as PartId, Location.Id as LocationId
F...
SELECT username, (SUM(rating)/count(*)) as TheAverage, count(*) as TheCount
FROM ratings
WHERE month ='Aug' AND TheCount > 1
GROUP BY username
ORDER BY TheAverage DESC, TheCount DESC
I know that's really close (I think) but it's saying 'TheCount' doesn't exsist in the WHERE clause and the ORDER clause.
The table is:
id, username,...
I'm in the process of designing a new database for an application. I'd like to be mindful of the security from the start (which should be the norm!). Anyone got a link to a resource describing the best way to use schemas to implement good security?
By using schemas, I mean not just dumping everything under the default dbo schema. Surel...