Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
karthikeyan.marlen
Starting Member
16 Posts |
Posted - 2011-11-29 : 01:22:55
|
HiI am having the empty table demo2 as subj1 mark1 subj2 mark2 subj3 mark3i am having the table demo1 assno name subj mark 1 aa tamil 901 aa english 801 aa science 702 bb tamil 100and i have created a stored procedure to insert records from demo1 to demo2it (storedprocedure) inserts records as----------------------------------------------subj1 mark1 subj2 mark2 subj3 mark3tamil 90 null null null nullnull null english 80 null nullnull null null null science 70 ---------------------------------------------but the actual format i want is subj1 mark1 subj2 mark2 subj3 mark3 tamil 90 english 80 science 70 --------------------------------------------------the storedprocedure i have created is-----------------------------------------------------create procedure inserttable (@no int)asbegindeclare @sql varchar(max);declare @cnt int;set @cnt=1;set @sql='insert into demo2 'while(@cnt <= @no)beginset @sql=@sql+'(subj'+cast(@cnt as varchar(2))+',mark'+cast(@cnt as varchar(2))+''set @sql=@sql +' ) select subj,mark from demo1 where sno=@cntendend-------------------------------------------------------------------please provide a solution for this,thanks in advancekarthikeyan |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
sql-programmers
Posting Yak Master
190 Posts |
|
|
|
|