sql

Hexadecimal sequence in Oracle

Hi all, I would like to generate 16 char length hex decimal value as sequence. My database is Oracle and would like to know is it possible to do so? I checked the SEQUENCE in Oracle but I think its only for numericals. Any idea would be great help. Thanks in advance, Abdel Olakara ...

Default values in Insert Select in SQL

How to pass default values in the Insert Select construction in SQL? I have a table: create table1 (field1 int, field2 int, field3 int default 1337) create table2 (field1 int, field2 int) I want to insert table2 into table1 with a construction similar to this: insert into table1 select field1, field2, DEFAULT from table2...

How to reverse the default ordering in Mysql?

In Mysql, when you execute a select SQL statement, there is a default ordering if you don't include a sorting clause, how to reverse the default ordering? Just add DESC? ...

backup SQL Server 2005 database without data

I have one stored procedure to backup the database. It will backup metadata as well as data. Is there any option to back up the database with out data. ie, back up only the schema (Empty tables). I don't want to script the database. ...

SQL:printing my own messages depending on query output

how can i print my own messages depending on the output of a SQL quesry. Eg: print "got it" when select * from emp wherempno=10; return atlest one record. else " not presnet" when the above quesry returns 0 records i just one one sql quesry and not a Pl/SQL code.I am using oracle 9 db. ...

simple sql query

I have 3 tables as follows. salesman(sid,sname) location(lid,lname) sales_loc(sid,lid) Now i want to print the sid and sname of saleman who has visited all locations. I want a SQL query and I don't want a PL/SQL code. ...

Select only first four lines, from Sql text field

Sql Server 2008 Express >> Visual Web Developer >> C# I'm pulling records out of the table like this: SELECT Name, Category, Review FROM ReviewTable This works fine but the Review field Type in SQL Server is text and is very long (think a magazine article). I only want to pull the first four lines from the Review field for each ro...

Copy trigger from one database to another

Is it possible, in a script executed in MS SQL Server 2005, to copy a trigger from one database to another? I've been asked to write a test script for a trigger my project is using. Our test structure is to create an empty database containing only the object under test, then execute a script on that database that creates all the other o...

Case ... When with strings in mysql

Hi I want to have some query like Select case column1 when column2 like '%Test%' then column 3 else 0 end FROM myTable in column2 there are varchars stored. Can someone help me with this? ...

Creating a range of numbers in an sql subquery

Is there a better way to generate a range of numbers in SQL than below? I'm using MySql. SELECT tens.x + ones.x + 1 FROM (SELECT 0 x UNION ALL SELECT 1 x UNION ALL SELECT 2 x UNION ALL ... SELECT 9 x ) ones CROSS JOIN (SELECT 0 x UNION ALL SELECT 10 x UNION ALL SELECT 20 x UNION ALL ... SELECT 90 x ) tens; ...

Using post array from paypal

I am using paypal to process payments on my site. Paypal returns the post array like [item_number1] =12 [item_name1] = My product name [quantity1] =3 [item_number2] =14 [item_name2] = My product name2 [quantity2] =5 [num_cart_items] 2 Insert step here now im just going in circles getting nowhere And then run the for loop for($i = 1;...

very simple SQL query in oracle 9

I have two tables: emp (empno,ename) address(empno,address) emp can have 0 or more address. I want to print a result as follows: when emp has 0 address then: eno,ename,"no address" when emp has 1 or more address then: enomename ,"address found" I am using oracle 9db ...

Get all records that contain a number

It is possible to write a query get all that record from a table where a certain field contains a numeric value? something like "select street from tbladdress where street like '%0%' or street like '%1%' ect ect" only then with one function? ...

How to get the latest created table in MySQL?

Hi, I have a MySQL database and every 6 months, a new table is created with the latest entries. What SQL command can get you the latest created table in a database? Many thanks ...

timestamp date today

Hi guys could you please help me with this. I know it is silly but can't find unswer anywhere: I have a query that shows events from the today time_stamp but I want to include today as well. How do I add this to this query? ... WHERE events.event_date > current_timestamp ORDER BY convert (event_date, date) ASC As it is formed it doe...

SQL query problem

I have two tables: emp (empno,ename) address(empno,address) emp can have 0 or more address. I want to print a result as follows: when emp has 0 address then: eno,ename,"no address" when emp has 1 or more address then: enomename ,"address found" I am using oracle 9db ...

Is it possible to ceate a DSn to my FTP Account

hi, i using sql2005, my hosting company allow me to use 300mb for my sql server. i wand to increase my sql database size but i have 300GB is available in my FTP account. Is It possible to create a DNS (some thing like MS ACCESS below) to my FTP account <% ConnStringHB = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath...

How can I use LIKE with an arbitrary word order in MySQL?

I need to use the LIKE keyword or some other similar operator for this purpose: In the database, the name and surname is stored as one column and it's in the order surname name (e.g. "Doe John"). I have a search bar with lets you enter your name and surname. When I am going to search, I require that if you enter name surname instead of...

Delete all but some rows - Oracle

Hi, I want to delete set of the rows from a table. I can decide which rows need to be deleted. I will delete the rows from table only if the count of rows is more than 5 (based on condition). Consider this sample data ID--Col1--Col2-- 1 A X 2 A X 3 A X 4 A X 5 A X 6 A X 7 A X 8 A ...

SQL query based upon object names stored within a table itself

Hi, I was wondering if there is a way of querying in MSSQL Server (2005 or 2008 or both) using table names / columns that are stored within a table themselves. Hopefully this makes sense but I imagine not so below is an example of what i mean, consider the tables: tableCollection ---------------------------- CollectionID ident p...