SQL Server : scenario with two tables -


i'm new sql server , learning. ive encountered problem. here scenario of problem.

there 2 tables, 1 addresses , other members.

previously, got 2 columns collecting dates addresses, 1 month , other year.

but decided add 2 columns collect date format (mm/dd/yyyy), instead of inserting data. use old data 2 old date columns month , year. , use identifying id members table , address table g1, g2, g3. identifying id primary key.

i decided manually realized got tons of data , take forever finish if 1 one. idea how this? using microsoft sql server management studio.

so should this.

  • month column = june
  • year column = 2015
  • fulldate column = 06/01/2015

all g1 should

given table like

create table dbo.addresses (     monthcolumn varchar(30),     yearcolumn int ) 

you add computed column table. since have month name, best bet going to concatenate date string , convert date (note, if integer, use dateadd() or, if you're running sql 2012 or more recent, datefromparts()

alter table dbo.addresses add monthyear convert(date, '01 ' + monthcolumn + ' ' + cast(yearcolumn char(4)), 106) -- 106 mask "dd mon yyyy" 

this rely on months being standard datenames. again, if you're able store months ints, life gets easier. is, how i'd approach it.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -