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.
Answer Posted / 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 |
Post New Answer View All Answers
What command would you use to add a column to a table in sql server?
what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration
What is data source in connection string?
What is raiseerror? What is raiseerror?
Why are you getting errors when creating a new odbc dsn?
When to use Inner join & when to use subquery?
List some advantages and disadvantages of stored procedure?
How to backup encryption key ?
What is an index. What are the types?
How many levels of sp nesting is possible?
What is difference between rownum and row_number?
How real and float literal values are rounded?
How many files can a database contain in sql server?how many types of data files exists in sql server? How many of those files can exist for a single database?
Does partitioning ssd reduce performance?
When to use null data driven subscription?