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 |
Does index slows down insert statements?
Is it possible for a stored procedure to call itself or recursive stored procedure?
What is the difference between 2-Tier architecture and 3-Tier architecture
15 Answers CTS, MCN Solutions, Oracle,
In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram
What is resultset concur_updatable?
What is the bookmark lookup and rid lookup?
What is exporting and importing utility?
What security features are available for stored procedure?
What are the properties of the transaction?
can you instantiate a com object by using t-sql? : Sql server database administration
What is transactional replication?
when inserting to a table how many rows will be effected using triggers
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)