sql

Can anyone please explain "storing" vs "indexing" in databases?

What is storing and what is indexing a field when it comes to searching? Specifically I am talking about MySQL or SOLR. Is there any thorough article about this, I have made some searches without luck! Thanks ...

Importing redefined SQL data from old app to new one.

Hi, I've nearly finished rewriting (with some new features) my Symfony (left a bit bad taste in mounth) application into Rails. There is some amount of data which I need to import from my old application into the new Rails app. Problem is that schema was dramatically changed and some foreign key values should be updated. I am wonder...

VARCHAR as foreign key/primary key in database good or bad?

Is it better if I use ID nr:s instead of VARCHARS as foreign keys? And is it better to use ID nr:s isntead of VARCHARS as Primary Keys? By ID nr I mean INT! This is what I have now: category table: cat_id ( INT ) (PK) cat_name (VARCHAR) category options table: option_id ( INT ) (PK) car_id ( INT ) (FK) option_name ( VARCHAR ) I COU...

Can you do queries against two databases if mysql_select_db was already used?

I have code that in the connection setup selects the database using mysql_select_db(). $link = mysql_connect('localhost', 'user', 'pass'); mysql_select_db("database1"); Can I later run a query against two databases such as: SELECT database1.row, database2.row FROM database1.table, database2.table WHERE database1.row = database2.oth...

Selectively restoring a database

I have been using this query: BACKUP DATABASE RentalEase TO DISK = 'C:\RentalEaseBackup\RentalEase.bak' WITH COPY_ONLY; GO To backup my database. Someone deleted something so now I have to restore it from a previous point in time, however I don't want to overwrite new changes (other than the deletions). What I was thinking I could do...

How Does Dateadd Impact the Performance of a SQL Query?

Say for instance I'm joining on a number table to perform some operation between two dates in a subquery, like so: select n ,(select avg(col1) from table1 where timestamp between dateadd(minute, 15*n, @ArbitraryDate) and dateadd(minute, 15*(n+1), @ArbitraryDate)) from numbers whe...

Regenerate GRANTs for roles across schemas

Similar to this question, I would like to know how to generate all GRANT statements issued to all roles in a set of schemas and a list of roles whose names end in "PROXY". I want to recreate statements like: GRANT SELECT ON TABLE_NAME TO ROLE_NAME; GRANT EXECUTE ON PACKAGE_NAME TO ROLE_NAME; The purpose is to help migrate from a devel...

My final mysql db, could someone check if the tables are correctly made?

I have these tables: category table: cat_id (PK) cat_name category_options table: option_id (PK) cat_id (FK) option_name option_values table: value_id (PK) option_id (FK) value classifieds table: ad_id (PK) (VARCHAR) something like "Bmw330ci_28238239832" poster_id (FK) cat_id (FK) headline description price etc.... posters table: po...

Spring Jdbc query execution

Does anyone know how what Spring Jdbc template method I could use to execute this 'upsert' or an alternative approach that would also perform the operations in one database call? UPDATE jasper_report SET Uri = 'update' WHERE ReportId = 99; IF @@ROWCOUNT = 0 AND Exists(Select 1 FROM report Where Id = 99) BEGIN INSERT INTO jasper_r...

Typing delay in SSRS 2008 report designer.

When creating a report using VS 2008 there is a typing delay in all the textboxes on the report designer. When I type in a textbox, whether a lone textbox or a textbox within a tablix, the text will not appear until approximately three seconds after I stop typing. I've recently installed SQL Server 2008 and I did not have this problem ...

SSIS: Oracle Multiple rows to one column output without STRAGG

Looking to generate a comma separated list of languages when the ID is the same. Table 1: ID | LangID 1 1 1 2 1 3 2 3 2 4 3 1 Table 2: ID | Language 1 English 2 Spanish 3 French 4 German Want to generate results that look like: ID | Languages 1 English, Spanish, French 2 French, German 3 Eng...

can't find my database space limit ?

Hello, in my webhosting, i can't find how much space i'm allowed to store in databases, is that counted with the files disk space? Thank you ...

SQL Error Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection when I'm trying to open the WebPart.

Hello everyone, I've created a custom Web Part for SharePoint that interacts with SQL. Everything worked fine on my DEV server. After I moved the WebPart to the client's server I started having problems. I get Error Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection when I'm trying to open the...

How to select 10 rows below the result returned by the SQL query?

Here is the SQL table: KEY | NAME | VALUE --------------------- 13b | Jeffrey | 23.5 F48 | Jonas | 18.2 2G8 | Debby | 21.1 Now, if I type: SELECT * FROM table WHERE VALUE = 23.5 I will get the first row. What I need to accomplish is to get the first and the next two rows below. Is there a way to do it? Colum...

Write a query to see the "date" in table is still to come or has passed by?

I want to write a sql query to find the rows with dates that are still to come. I was trying something like this: $now_time = time(); $queryEvents = "SELECT summary, startdate FROM c7_events AND startdate > $now_time WHERE users_id = $users_id"; but this is not working because the startdate in table has data like: 201...

SQL need most efficient way to select items list with sublists?

Lets look at some very simple example, have 3 tables: dbo.Person(PersonId, Name, Surname) dbo.Pet(PetId, Name, Breed) dbo.PersonPet(PersonPetId, PersonId, PetId) Need to select all persons with theirs pets if person has any.... for ex. in final application it should look smth like: whats the most efficient way: Select all persons ...

SQL - join up two separate sql queries

Hi - I have a table that stores the page hits on a web application, storing unique_row_id http_session_id page_name page_hit_timestamp ---------------------------------------------------------------- 0 123456789 index.html 2010-01-20 15:00:00 1 123456789 info.html 2010-01-20 15:00:05 2 ...

Surround Variable with Single Quotes when Passing SQL Smalldatetime

I have a problem/question that I may have been staring at too long today. I have a stored procedure that receives data from an web application. The data comes in as smalldate time format. I am trying to pass this information to a second stored procedure but the second one won't fire unless the data is in single quotes. Would it be ...

How should I write PHP $_POST vars in a mysql_query function?

Hi all, In accessing my database, I have the user fill out a form, and in the target page, the posted values are used in the resulting MySQL query. $query = mysql_query("SELECT pass FROM database WHERE user='$_POST[user]'"); However, for some reason or another, MySQL doesn't like my using a $_POST variable in the command, and it only...

Designing archive in database. Some patterns maybe?

We are currently doing an web application which one of the functionality is to create Events by the user. Those events can be later on deleted by the user or administrator. However the client requires that the event is not really physically deleted from database, but just marked as deleted. User should only see non-deleted events, but ad...