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 |
Ratz03
Starting Member
27 Posts |
Posted - 2014-11-17 : 16:25:39
|
am a newbie to sql..i need to writw a stored proc to read table A into new table b with some new cols. see below.please help...database A table 1 name age gender city dobabc 10 m kl 04-Jun-80 database2 table 2 source year from dob name age cityA 1980 abc 10 kl |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-11-17 : 17:52:38
|
Table 2 has seven columns but only five values. Can you clarify? No amount of belief makes something a fact. -James Randi |
|
|
Ratz03
Starting Member
27 Posts |
Posted - 2014-11-18 : 04:00:07
|
please read (year from dob) as 1 column |
|
|
AASC
Starting Member
24 Posts |
Posted - 2014-11-18 : 04:45:17
|
@Ratz use this ---- Use database1use database1GO---- create temp tablecreate table A( name varchar(20),age int,gender char(1),city Varchar(20),dob datetime)---- insert dummy datainsert into Aselect 'abc', 10 ,'m' ,'kl' ,'04-Jun-80'--- Query for stored procedureCreate procedure InserttabledataASinsert into database2.dbo.[table 2]select 'A' [source], datepart(yy,dob ) [year from dob] ,name , [age], [city]from database1.dbo.A |
|
|
Ratz03
Starting Member
27 Posts |
Posted - 2014-11-18 : 08:04:10
|
thankyou aasc. |
|
|
|
|
|
|
|