Sunday 15 September 2013

TSQL Update Statement MS SQL Server 2008 R2 -


The Fk value in a table data table to update my updating PK ID.

The data table has date ranges and the table to be updated is the date of birth date (month, day, year). My update statement could loop through RBAR (row by the Angling row) through all records, but I was hoping to use another set based solution. I have tried to use the case statement and the table is included in the clause on the updated attendance but this problem is about how to find out how it has reached. Here's my attempt in the table schema and update statement

  Table 1 person: table [dbo]. [TFI_PERSON] ([PERSON_ID] [INA] identity (3500,1) NOT NULL, [Horoscop_sani_aidi] [Int] NULL, [Diobeediai] [Int] narwhal, [DOB_MONTH] [Int] NULL, [Diobi_aiiiar] [Int] tap ,   

table 2 coil

  table [dbo]. [TFI_HOROSCOPE_SIGN] ([HOROSCOPE_SIGN_ID] [int] NULL not identified (1,1), [ HOROSCOPE_SIGN] [nvarchar] (100) nOT nULL, [HOROSCOPE_BEGIN_DATE] [Datetime] No [Horoskap = END_DATE] [datetime] nOT nULL,   

Try (s) 1 & amp; 2

  update p set p. HOROSCOPE_SIGN_ID = HS [HOROSCOPE_SIGN_ID] Dioktikaikaikpi.as.ank p join [DBO]. [Tifai_acoarosooso POSOSIS] HS on P. [Horoscope_sniiid] = HS. [Horoscope_sniiid] Where Cast (DOB_AAIARAAR N NHARAR) + '-' + Cast (NVHARA in DOBMNSS) + '-' + (DOB_DAY as ANHRAAAR) About HS [Horoscope_Jap] and HS [Horosop_com] END_DATE Update dbo.TFI_PERSON SET HOROSCOPE_SIGN_ID = (Select HOROSCOPE_S IGN_ID FROM dbo.TFI_HOROSCOPE_SIGN WHERE CAST (CAV (NVARCHAR as DOB_YEAR) + '/' + CAST (as NVARCHAR) DOB_MONTH) + '/' + CAST (NOHARAR's The form Anaiacaaraar) as Datstii) [HOROSCOPE_BEGIN_DATE] and [HOROSCOPE_END_DATE])   

Thanks for the help.

What was this in my mind? ..

  Update P set HOROSCOPE_SIGN_ID = HS [HOROSCOPE_SIGN_ID] dbo.TFI_PERSON join [dbo] as P [TFI_HOROSCOPE_SIGN] as HS on Cast (Cast (P. DOB_DAY + P.DOB_MONTH * 100 + P.DOB_YEAR * 10000) in four (8)) as the date) between HS. [HOROSCOPE_BEGIN_DATE] and HS [HOROSCOPE_END_DATE]   

Of course, it assumes that the TFI_HOROSCOPE_SIGN table TFI_Person has date ranges for covering all the possible dates of birth of people.

No comments:

Post a Comment