sql

MySQL - convert phone number data?

I have a MySQL InnoDB database. I have a 'phone_number' field. My data is dirtly in the sense that sometimes my data is: (111) 222-3333 111-222-3333 111.222.3333 (111) 222 3333 How can I strip all spaces and parenthesis from my 'phone_number' field to only store my phone_number in the following format '1112223333'? What would the S...

oracle 10 performance issue with Select * from ...

sql : select * from user_info where userid='1100907' and status='1' userid is indexed, the table has less than 10000 rows and has a LOB column. The sql takes 1 second (I got this by using "set timing on" in sqlplus). I tried to use all columns names to replace *,but still 1 second. After I removed the LOB column ,the sql takes 0.99 s...

Can i get entity filled via Entity SQL ?

Hi. Can i do something like that: I got some entity Customer with Id, Name, Comment Now i want to get this entity from context with filled id and Name and Comment must be empty. I don't want to query it from database. in T-SQL it simply: Select Id, Name from Customers where id=4 Can i do that trick with Entity SQL something like th...

How can I make change for existing date value in SQL Server into new value?

Does anyone know how can I make change for existing date value in SQL Server into new value? Example: Declare @StartDate DATETIME; SET @StartDate = '2010-07-07 00:00:00' Which I hope to declare another variable @DATETIME2 DATETIME based on @StartDate value changed into '2010-07-07 08:00:00' instead of default manually hard code it ...

How to Quiry Pivot 4 Tables

Dear Sir/Madam Could you help me to check as below: DECLARE @tblCity TABLE (CityID INT, CityName VARCHAR(100)) DECLARE @tblHotel TABLE (HotelID INT, HotelName VARCHAR(100)) DECLARE @tblTourClass TABLE (TourClassID INT, TourClass VARCHAR(100)) DECLARE @tblTourHotel TABLE (id INT, CityID INT, HotelID INT, TourClassID INT) INSERT IN...

MySQL - how to front pad zip code with "0" ?

In my MySQL InnoDB database, I have dirty zip code data that I want to clean up. The clean zip code data is when I have all 5 digits for a zip code (e.g. "90210"). But for some reason, I noticed in my database that for zipcodes that start with a "0", the 0 has been dropped. So "Holtsville, New York" with zipcode "00544" is stored in m...

How to get first element by XPath in Oracle

In my Oracle db I have records like this one: <ROOT> <Event> <Type>sldkfvjhkljh</Type> <ID>591252</ID> </Event> <Data> <File> <Name>1418688.pdf</Name> <URL>/591252/1418688.pdf</URL> </File> <File> <Name>1418688.xml</Name> <URL>/591252/1418688.xml</URL> </File> </Data> </ROOT> I n...

Encrypting Whole Database

I need to encrypt whole databse, not any specific column in the database. This should be done in SQL 2008 or in SQL 2008 Express edition If any one can, do favour for this ...

Regarding Oracle Error

Hi, I am getting the below oracle error. I checked the test scheme for any constraint name CMF_CMP using toad. But i am unable to find it. How do i detect the reason for failure and how to resolve it. ERROR at line 1: ORA-20001: -2298: ORA-02298: cannot validate (TEST.FMF_CMP) - parent keys not found ORA-06512: at test.test_SYN", ...

How to convert timezones in SQL Server 2005?

Hi All my times are in UTC timezone now I need to somehow convert it to the users timezone(I have it stored in the db as well and uses the ids of the windows timezones). How can I do this in SQL Server 2005? Edit So I tried to do that extended stored procedure but with Timezoneinfo I get this error Deploy error SQL01268: .Net Sql...

SQL statement to truncate all data from all tables in the database

Possible Duplicate: Truncate all tables in a MySQL database in one command? how to delete all the data from all tables in the database. ...

what does "delete from table where NULL = NULL" means ?

what does "delete from table where NULL = NULL" means ? ...

SQL query to get all users not in group

I have user and group tables set up as the following. users id int groups id int users_groups user_id int group_id int Example data: +---------+----------+ | user_id | group_id | +---------+----------+ | 1 | 1 | | 1 | 2 | | 2 | 1 | | 3 | 2 | | 3 | 3 | | 4 ...

How to get time part from Sql Server 2005 datetime in HH:mm tt format

How to get time part from Sql Server 2005 datetime in HH:mm tt format e.g. 11:25 AM 14:36 PM ...

SQL Server Schema to Schema Migration

I would like to know which one is the best approach for migrating existing DB data to another new DB with entirely different structure. I want to copy the data from my old DB and need to insert the data in new DB. For me the table names and column names of new DB is entirely different. I am using SQL Server 2008. ...

SQL interview question

I got following question on an interview: Which SQL mechanisms allow user to browse tables sequentially? ...

SQL Return only where more than one join.

Not sure how to ask this as I'm a bit of a database noob, What I want to do is the following. table tb_Company table tb_Division I want to return companies that have more than one division and I don't know how to do the where clause. SELECT dbo.tb_Company.CompanyID, dbo.tb_Company.CompanyName, dbo.tb_Division.DivisionName FROM d...

SQL Server, Converting a select mechanism from "and" into "or"

Hello all, I have a web based program which chooses some records from a database using a checkboxlist. (my check box list sends parameters to a stored procedure and I use the result of stored procedure). Here how my check box list looks like Overflow [] (sends param1) Open Records [] (sends param2) Records with 4...

Database connection, check data, login page

Hi, I'm doing Major Project on my final year and I'm very new to Android plus I;m not good at codings. I need help with my login page. I've created something like a database connection java file which is this: package one.two; import java.util.List; import android.app.ListActivity; import android.content.Context; import android.d...

SQL Server / TSQL Updating a table with a unique constraint

Hi, If I have two tables, say: Clients ( ClientID int primary key, ClientName varchar(50) not null ) and Addresses ( AddressID int primary key, AddressLine1 varchar(50), etc.. ClientID int not null, IsPrimaryAddress bit not null ) with a unique constraint across (ClientID, IsPrimaryAddress), how can up date those tab...