sql

sql : How to move full text catalogue

Hi, I want to move full text catalogue for 1 database to a different location on same SQL server. I am using SQL 2005. One of the source said: SQL Server 2005 full-text search provides the ability to easily detach and move full-text catalogs in the same way that SQL Server database files may be detached, moved, and re-att...

EF- How to do a 'Not In' using Linq to Entities

Hi- I'm using the Entity framework 3.5 and am having trouble running this query. I have the following entities: Applicant, application, and applicationstatusHistory (tracking job applicants) I'm looking for matches in Application where there are no matching applicationids in applicationstatusHistory with an id of -insert param here-. T...

Sql Server 2008 Cross-database table linking (relationships)

Hi guys, I have a bit of an issue, and to be honest I don't think there's an answer, but I'll give it a try anyway. So I have two databases [A]->Company and [B]->Product. Both databases have a Country table which is then linked to other tables in each individual database. The problem is that the data between the two Country tables is a ...

Getdate() equivalent for Jet / Access database. Need last month records.

Hello, I was reading other questions posted and found many examples to retrieve last month records. I am using Visual Studio 2008 query builder to retrieve records from an Access mdb and when I enter the following query it is displaying me an error that getdate is not a valid function: where [Transaction Date] between dateadd(...

Get Rows Where timestamp Column is 2 days Old

Hey guys, I have a table that has a column with the timestamp in sqlite3. It is default to the CURRENT_TIMESTAMP such that when the row gets inserted, the current time is inserted. Now I am trying to fetch the rows that have been inserted 2 days ago or more. I wonder if that makes any sense. Reading the documentation I came up with: SE...

JSON VIEW using GROUP_CONCAT question

Hey DBAs and overall smart dudes. I have a question for you. We use MySQL VIEWs to format our data as JSON when it's returned (as a BLOB), which is convenient (though not particularly nice on performance, but we already know this). But, I can't seem to get a particular query working right now (each row contains NULL when it should con...

SQL Query Source Code

Hi all, I have 3 tables. One table has all the people, [Pat], each with a unique [PatId]. The second table has all the insurance company information, [Ins], each with a unique [InsId]. The third table has the patient insurance info, [PatIns]. In the [PatIns] table, some patients (also [PatId]) have secondary or 3rd insurance and it deno...

Two level group by, order by

what is the linq equivalent of the following: SELECT Mytable.A, MyTable.B, SUM(MyTable.C) FROM MyTable GROUP BY Mytable.A, MyTable.B ORDER BY Mytable.A, MyTable.B This is trivial in SQL, but seems to be very difficult in LINQ. What am I missing? ...

How to view the calls the sql server receives in live mode?

Hi, Is there any tool, or any VS debug option i'd use to watch all the calls my c# application, sends to the SQL server 2k8? I'd like to know how efficient is my c# code at doing the calls, like how many SELECTS is it sending at certain time/situation. Thanks. ...

Can this PHP code be simplified to improve performance?

The goal of this code, is to get all brands for all stores into one array, and output this to the screen. If a brand exists in multiple stores, it will only be added once. But I feel I have too many for loops, and that it might choke the CPU on heavy traffic. Is there a better solution to this? function getBrands($stores, $bl) { ...

Does ORM for social networking sites makes any sense?

The reason why I ask this is because I need to know whether not using ORM for a social networking site makes any sense at all. My argument why ORM does not fit into social networking sites are: Social networking sites are not a product, thus you don't need to support multiple database. You know what database to use, and you most likel...

SOLR commit and optimize questions

I have a classifieds website. Users may put ads, edit ads, view ads etc. Whenever a user puts an ad, I am adding a document to solr. I don't know however when to commit it. Commit slows things down from what I have read. How should I do it? Autocommit every 12 hours or so? Also, how should I do it with optimize? Please give a detaile...

regist payment for each month of the year using oracle data

I have the following tables: Employees with level (rank or wtv you may call it): income_value,id, etc. INCOME that stores the rank vs. the income value (very tinny and static) REGIST_INCOME table with the following columns: ID_REG; ID_EMPLOYEE; MONTH_and_Year_OF_PAYMENT DATE (I want to format to yy.mm); DATE_OF_PAYMENT DATE ...

Problem in oracle trigger query

Can anyone please tell me what is wrong with this query? create trigger Test_trigger before insert on Test for each row begin select TestSequence.nextval into :new.id from dual; end;/ When I run this query, I get the following error: ERROR at line 1: PLS-00103: Encountered the symbol "end-of-file" when expecting one of th...

quotes in queries

I have a mysql query which requires that parameters be enclosed in either "" or '', if I have an array passed to this function: function orderbyfield($column, array $selection) { // will it be alright (secure) to do this? foreach ($selection as $s) { $s = '"' . $s . '"'; } $string = implode(',', $selection) return array($column...

What is the convention when relevant data needs to be stored in a join table?

Suppose you have a data model that is something like class Question has_and_belongs_to_many :choices end Now suppose, on that choices model, there is a position column. What is the best way to access that information without having horrible messy queries / models? The beauty of has_and_belongs_to_many is that it keeps things concis...

Is there a way to filter sql execution plans by specific operator?

I have a great bunch of sql server statements that run on sql server 2008 I try to inspect its execution plans. Actually it generates a great deal of execution plans. I want to show only the execution plans that have a specific operator(s). e.g I want to get the execution plans that have Table Scan operator. Any way to do something like...

Problem with SQL addition

Please, I'm trying to get some total value of user earned points in few distinctive counts, but everything is from same table. SQL: SELECT o.author_id, SUM(o.vote_value) AS vote_value, n.best AS best_sum, (SUM(o.vote_value) + (10 * n.best)) AS total FROM comments o LEFT JOIN ( ...

SQL Server String parsing for special characters

I need a solution (t-sql function / procedure) to parse an SQL Server varchar(max) and eliminating all special characters and accents The output of this string will be transformed to a CSV file using an AWK script that breaks on special characters like '&', '%', '\' and all accent characters that on convert turn into unknown characters...

Correct this Rails/ruby method for me, please?

I've a post model with act-as-taggable-on gem. Both tables have timestamps. I started with def tags @posts = current_user.posts.find_tagged_with(params[:tag], :order => "@posts.tags.updated_at DESC"]) end And when that didn't work, I tried changing things and ended up with this mess. def tags @posts = current_user.posts.find_t...