Please give me the SP for the below scenario. I have two
tables named Table1 and Table2...I need to fetch record by
record from Table1 and insert the record in to table2 where
the value in the sno column of the table1 is even number.
Answers were Sorted based on User's Feedback
Answer / meenaprasanna
insert into table2(Column1,Column2) select Column1,Column2
from Table1 where Column1 %2 ='0'
| Is This Answer Correct ? | 14 Yes | 2 No |
Answer / mythili
insert into table2(Column1,Column2) select Column1,Column2
from Table1 where Column1 %2 ='0'
| Is This Answer Correct ? | 13 Yes | 1 No |
Answer / rajesh.a
insert into table2(Column1,Column2) select Column1,Column2
from Table1 where Column1%2 = 0
| Is This Answer Correct ? | 9 Yes | 0 No |
Answer / priyanka malondkar
First make a function like this
create function functionname(@sno int)
returns number;
declare check;
begin
check=@sno%2
if check=0
return 0;
else
return 1;
Then the query will be
declare no;
insert into Table2(a,b,c) values select (a,b,c) from Table1
where no=functionname(sno) and no=0;
Kindly check.
In case of any syntax error please excuse as i have not
checked it of sql sever.
| Is This Answer Correct ? | 5 Yes | 1 No |
Why I am getting this error when renaming a database in ms sql server?
Advantages and disadvantages of stored procedures.
how to find number of columns in a table in sql server 2000 and 2005 also
What is the fastest way to permanently delete a 1 million row table named customers?
What is database normalization?
7 Answers Deloitte, Digicel, JPMorgan Chase, Verifone,
what is the main difference between after trigger and instead trigger.
How check triggers in sql server?
what protocol both networks use? : Sql server database administration
What is an indice?
Why union all is faster than union?
Which is the best place or learning center for MS SQL?????In Bangladesh?????
What are the differences between left join and inner join in sql server?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)