sql

MySQL function which takes a set of strings?

There's a mysql function which works like this: SELECT * FROM myTbl WHERE name ???('bob', 'jane', 'sally') The above query should return all records where name is bob, jane, or sally. Where it says ??? above is where the function name should be. Can anyone remind me what that function is called? ...

Visual Studio 2008 + Sql 2008 best practices

The basic problem is that upon trying to uninstall the default SQL 2005 express and install SQL 2008, it is no longer connectable through either Visual studio or the Management Studio. I think at this point (as I have been meaning to for sometime) a reinstall of Windows will be quicker than a repair. When I have Windows reinstalled, wha...

Where can i see the query generated by subsonic?

I need to see how subsonic generates the SQL Query string. ...

Subsonic: How to exclude a table column so that its not included in the generated SQL query

I need to insert a record to a table. Subsonic builds the query something like this (as far as i know): INSERT INTO Table1 (Title, Description, RowVersion) VALUES (@Title, @Description, @RowVersion) But i want to remove the RowVersion column from the SQL query bacause its autogenerated by the sql server. How can i do that? ...

Does SAS Proc SQL ever use an index when merging

Consider the following (admittedly long) example. The sample code creates two data sets, data one with "key" variables i,j,k and data two with key variables j,k and a "value" variable x. I'd like to merge these two data sets as efficiently as possible. Both of the data sets are indexed with respect to j and k: the index for the first d...

store and query xml data in MySQL

what are the good options to store xml structured data and query the data in MySQL? I know from mysql5.1.5 there is a function ExtractValue() to query the data directly, but due to certain limitations I can only use mysql5.0.x. what I need is to store the data in simple xml format, such as <person> <name>My Name</name> <gender>male</ge...

INSERT conflicted with foreign key - SQL Server bug?

UPDATE: the issue does not happen when run against SQL Server 2008. So this is something strange (or wrong) with SQL Server 2000. I try to do a simple insert on SQL Server 2000: INSERT INTO UserAddresses (UserId, AddressId) SELECT UserId, Id FROM Addresses and I get this: INSERT statement conflicted with COLUMN FOREIGN KEY ...

How to optimize this SQL query?

I have a database with questions and answers that get translated into all languages that site is used by. But when a question is not translated yet I want to show that question in english language. So a gettext-like behavior. My current SQL query for this looks like this: SELECT * FROM questions_view WHERE `language` = "de" AND `#paren...

sql full text index problem with "score" not updating in a timely fashion

Have full text index on a table for the purpose of searching and producing a list of results based on relevance, I assign relevance based on the highest "score" from the full text index. The table contains 3 columns, a unique ID, a text field in the type (varchar), and the third is a timestamp of the last edit. The full text index only ...

monthly breakdown of table data, date stored as epoch time

I have a mysql table that contains a date field in epoch time format. I need to count how many rows I have for each calendar month of the year. I don't even know where to start. Thanks in advance. ...

SQL Query Duplicate Removal Help

I need to remove semi duplicate records from the following table ID PID SCORE 1 1 50 2 33 20 3 1 90 4 5 55 5 7 11 6 22 34 For any duplicate PID's that exist I want to remove the lowest scoring record. In the example above ID 1 would be remove. I'm tr...

Getting unique rows/values in SQL

Getting unique rows/values in SQL. I have same some data like this valueA ValueB ValueC test "Value1" "Something" test "Value1" "Something else" test2 "Value1" "Something else" So then I want to get the first two rows since valueC is different and then I also want row 3. but say Row 4 is test "Value1" "Somethin...

how to do a select on like values from multiple columns in sql

I have two tables with columns: Genres: ID, genre Adjectives: ID, adjective_title I need to do a select that returns the matching values from both tables columns with the 'like' syntax. For example if "ep" was the value entered using 'like' the results would look like: result_column: epiphonic (from genres table) epic (from adjecti...

query part of a binary field from sql table

Hello All, a bit newb question: in my DB I've got a table with a binary field. I'd like to fetch not that whole field in a request, but rather part of it, preferably using ODBC. Is it at all possible? I'm using PostgreSQL 8.3 - in case a solution exists for that specific DBMS. Thanks. Getting data part-by-part seems to be possible with ...

Using Same Stored Procedure for Both Insert and Update in Entity Framework

I have a stored procedure that does both the insert and the update in one fell swoop (if the id == 0 then it's an insert, otherwise, update). I'd love to use this for both the insert and the update methods in Entity Framework, but this isn't looking feasible. Am I correct that I'll have to split the methods into two different stored proc...

SQL CORRELATION

I have this query: SELECT COUNT (DISTINCT CUSTOMER_ACCOUNT.ID) AS NUMBER_OF_ACCOUNTS FROM CUSTOMER_ACCOUNT INNER JOIN ACCOUNT ON CUSTOMER_ACCOUNT.ACCOUNT_ID=ACCOUNT.ID INNER JOIN CUSTOMER_ACCOUNT ON LOAD_ACCOUNT_DETAIL_0.ID = CUSTOMER_ACCOUNT.ID WHERE Convert(datetime, convert(char(10), [CUSTOMER_ACCOUNT].CREATED_ON, 101)) BETWEEN ...

Query I need to be sped up

I have this query in SQL Server 2005: SELECT J.JobID, dbo.tblCustomers.Name AS CustomerName, J.CustomerJobNumber, J.JobName, (CASE WHEN [tblCustomers].[CoreCust] = 0 THEN 'AUXILIARY' ELSE 'CORE' END) AS Department, J.JobStatusID, dbo.tblJobTypes.JobType FROM dbo.tblJobs (NOLOCK) AS J IN...

Convert "flat" SQL query result into table structure

I've got a Sql Table that returns a result as follows: Amount Descrip ---------------------------- 1.34 Group1 Description1 2.36 Group2 Description2 5.46 Group3 Description3 4.54 Group1 Description4 6.23 Group2 Description5 I need to make it look something like this. Descrip Group1 Group2 Group3 ----------...

What tools are available to test SQL statement performance?

In the never-ending search for performance (and my own bludgeoning experience), I've learnt a few things that could drag down the performance of a SQL statement. Obsessive Compulsive Subqueries Disorder Doing crazy type conversions (and nest those into oblivion) Group By on aggregate functions of said crazy type conversions Where fldID ...

Cross-database queries with numbered database name

Hi there, I'm a bit of a novice when it comes to SQL Server 2005. I have a database containing most of the stored procedures and tables (we'll call it 'GrandDatabase'). Each user has its own separate database named after the user's numbered ID. So I have a database list as follows, for example: GrandDatabase 100 101 102 ... I need ...