sql

Mysql - Select words from text

Hello guys, I have a table contains 300 locations name (Pris, London,...) is there a way (query) to select locations from specified text. for example: " Transport for London (TfL) is in talks with its American, Australian and European partners about issuing a single contactless card for Paris, New York". I want a query to get: Lond...

Updating multiple rows with different values

I got this table in my MySQL database, 'users'. It has the fields 'id' and 'value'. Now, I want to update lots of rows in this table with a single SQL query, but many rows should get a different value. Currently, I'm using this: UPDATE users SET value = CASE id WHEN 1 THEN 53 WHEN 2 THEN 65 WHEN 3 THEN 47 ...

Storing unknown datatype in MS SQL Server Database

Hi, Does any one has an idea of whats the best practice to store an unknown data type in a table. Basically I would need to store types like bit, smallint, int, real and nvarchar in the same "value" column, for later interpretation by a .NET application. I was trying to achieve the best possible solution not to compromise the performan...

I cant reach my new SQL instance

I was using a older version of SQL on my server, and it worked fine when only typing the servername,, I could directly connect to the server, I recently installed a new instance of SQL, and Iam trying to connect to the new instance but it dowsne't work. SERVERNAME/New_instance CAn someone help me out? How can I reach the new SQL se...

How to set Database Audit Specification for all the tables in db

I need to create an audit to track all CRUD events for all the tables in a database , now i have more than 100 tables in the DB , is there a way to create the specification which will include all the tables in the DB ? P.S : I am using SQL Server 2008 ...

Table Design For Multiple Different Products On One Order

If I were to have an online shopping website that sold apples and monitors and these were stored in different tables because the distinguishing property of apples is colour and that of monitors is resolution how would I add these both to an invoice table whilst still retaining referential integrity and not unioning these tables? ...

"Debug"(get information) on a running stored procedure in MS Sql Server

Hello, i aked myself if it is possible in MS SQL-Server 2005 to get information of a running stored procedure. Because meanwhile it is executing for more than 8 hours, i would like to know on what step it is or if it is even actually running at all. MS SSMS says that it is still executing the query. Thanks in advance, Tim ...

Can I use sql bulk copy to copy data within the same server ?

Can I use sql bulk copy to copy data within the same server ? ...

How to reverse values in a string in T-SQL

Using T-SQL, I'm trying to find the easiest way to make: "abc.def.ghi/jkl" become "abc/def/ghi.jkl"? Basically switch the . and / Thank you ...

How to fetch data from oracle database in hourly basis

Hi all, i have one table in my database say mytable, which contents request coming from other source. There is one column in this table as Time, which stores date and time(e.g. 2010/07/10 01:21:43) when request was received. Now i want to fetch the data from this table on hourly basis for each day. Means i want count of requests database...

Is it possible to pass a parameter to trigger in SQL server database?

Table can have trigger on insert/delete/update. Trigger will be fired internally by DB engine. Is it possible to pass a parameter to trigger in SQL server database like StoreProcedure? ...

Can I specify the default SQL Server with two named instances installed?

I have SQL 2005 Express installed. I then installed SQL Server 2008 R2 and am running both instances successfully. They are named: COMPUTERNAME\SQLEXPRESS (2005) COMPUTERNAME\INSTALL2 (2008) I am trying to figure out how to specify the 2008 instance as the default server. I have tried: Data Source=.\local; ... Data Source=.; ... Da...

SQL Filegroup degrading performance

On our dev boxes, our database resides entirely in the PRIMARY filegroup, and everything works fine. On one of our production servers, recently upgraded from 2005 to 2008, we noticed it was performing slower than it should. On this machine, there are two filegroups - PRIMARY and INDEXES. Both filegroups contain 1 file per logical vo...

Help with Simple Query?

I have the following tables I need to find out the sum. Table A ID Name 1 Jason 2 Peter 3 Ravi Table B ID ID_SEC 1 11 1 12 1 13 2 21 2 22 2 23 3 31 3 32 3 33 Table C ID_SEC Value Include_Ind 11 100 Y 12 200 Y 13 300 N 21 10 Y 22 20 N 23 30 N 31 1000 N 32 2...

cakephp find all posts that have comments

I created a simple blog that has posts and comments. I want to find all the posts that have at least one comment and also find all the posts with no comments. Is there a cakephp way to do this? I.E. maybe something like $this->Post->find('all', ???); I ended up writing my own query, the example below finds all the posts with at least ...

How do you store variables fields ?

Hi, I've a database where I've comments, votes, galleries, images, etc... For examples, galleries and images can be commented using the same form, then I'll store it in a single table, comment. I'm wondering how would store this type information in the comment table? Using a ENUM type, a foreign key against a type table, hardcoded on i...

How do I use rows-as-fields in a SQL database

I've got a SQL related question regarding a general database structure that seems to be somewhat common. I came up with it one day while trying to solve a problem and (later on) I've seen other people do the same thing (or something remarkably similar) so I think the structure itself makes sense. I just have trouble trying to form cert...

how to get values of array out

I have this array $pv->orderRecordsArray = array(); foreach($order->records as $i=>$orderRecord){ $pv->orderRecordsArray[] = $orderRecord->orderRecordID; } // print_r($pv->orderRecordsArray) for example // shows Array ( [0] => 46839 [1] => 46840 [2] => 46841 ) I need to use the array values from above in my sql statemen...

SQL subquery with COUNT help

I have an SQL statement that works SELECT * FROM eventsTable WHERE columnName='Business' I want to add this as a subquery... COUNT(Business) AS row_count How do I do this? ...

Need the more recent between two DATETIME's in SQL

I have two SQL DATETIME's that I need to compare. I need to set the value of a column to be the more recent date between the two. Is there a function for this? ...