February 11, 2010 at 9:06 am
Hi ,
I have a table A which i need to include column YearWeek =XXYY
where XX=right(Year,2),YY=Week ,The Year plus week that date column(it is there in b table) falls in (c table which contains the date for year and week)
and i need to join b table with c table to get XXYY into my table A.
how can i insert using insert syntax please help me
Please correct me if i am wrong
February 11, 2010 at 9:57 am
your question was missing a lot of things that we'd need to join your two tables together, ket alone insert into one of them.
give us some more details: the CREATE TABLE scripts are required for a coherent answer.
as far as getting the year and week as a 4 digit varchar,, here's one way to do it:
--this returns "1007" note the preceeding zero for week 7
select RIGHT(YEAR(getdate()),2) + RIGHT('00' + CONVERT(varchar(2),datepart(wk, getdate())),2)
Lowell
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply