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 |
tell me what are the steps you will take to improve performance of a poor performing query? : Sql server database administration
List out the differences between global and local temp tables in sql server?
How do I find the size of a sql server database?
How to reaname table name without using sp_Rename in sql server..?
What different steps will a sql server developer take to secure sql server?
I create a separate index on each column of a table. What are the advantages and disadvantages of this approach? : Sql server database administration
How to display a past time in days, hours and minutes?
What is difference between views and stored procedures?
What is the beast way to write CTE in SQL Server ?
Name few of the dcl commands in sql?
How to add a new column to an existing table with "alter table ... Add" in ms sql server?
How to retrieve range of 10th rows to 20 th rows from total rows from a database table.? (Not from Dataset)
10 Answers Cognizant, Infosys,
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)