shwelopo
asked on
SQL query
I'm trying to list the numbers between 515000 and 516000 to insert into an empty table (nvarchar type)
FOR ORACLE
IF the table is already there..
INSERT INTO yourNewTable(Column1,Colum n2....etc)
SELECT Column1,Column2....etc
FROM yourTable
WHERE NumberCol >= 515000 and NumberCol<= 516000;
IF the table is NOT already created
CREATE TABLE yourNewTable
AS
(
SELECT Column1,Column2....etc FROM yourTable
WHERE NumberCol >= 515000 and NumberCol<= 516000
);
IF the table is already there..
INSERT INTO yourNewTable(Column1,Colum
SELECT Column1,Column2....etc
FROM yourTable
WHERE NumberCol >= 515000 and NumberCol<= 516000;
IF the table is NOT already created
CREATE TABLE yourNewTable
AS
(
SELECT Column1,Column2....etc FROM yourTable
WHERE NumberCol >= 515000 and NumberCol<= 516000
);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DO NOT use RECURSION
And the reason for that is...?
»bp
>>And the reason for that is...?
It slows down the things..we need to use SET based approach in all RDBMS's as they are naturally fast in nature as you play with the entire DATASET.. ..But for one time activity anything will do as i mentioned in my last post.
It slows down the things..we need to use SET based approach in all RDBMS's as they are naturally fast in nature as you play with the entire DATASET.. ..But for one time activity anything will do as i mentioned in my last post.
For generating a sequence of 1000 values the RECURSIVE approach works just as fast and I personally find the code easier to write and understand.
»bp
»bp
Yes you can use..its perfectly alright but it is not the preferred method...for DB engine.
Do not worry about the conversion, DB will implicitly convert the INT values to NVARCHAR.
IF the table is already there..
INSERT INTO yourNewTable(Column1,Colum
SELECT Column1,Column2....etc
FROM yourTable
WHERE NumberCol >= 515000 and NumberCol<= 516000
IF the table is NOT already created
SELECT Column1,Column2....etc
INTO yourNewTable
FROM yourTable
WHERE NumberCol >= 515000 and NumberCol<= 516000