database - T-SQL - create new foreign key relationship from non-normalized data -


I am trying to find the best transit-SQL to change non-relational tables in more harmony, and Support

Suppose I have a table table

  ID name USState 1 Apple Washington 2 Pineapple Hawaii 3 Orange Florida 4 Peach Georgia etc.  

I want the state to be your table with an ID and name:

  USSTATE (name) in INSTERT USState separate from FRITT Now I have a table USSTAT  
  ID name 1 Alabama 2 Alaska etc.  

How can I update the USState value to Table Street to indicate the usage of USSTATE?

I can state it by state

  DECLARE @USSTATE nvarchar (100) set @USSTATE = 'Alabama' update set Fruit USState = (SELECT Id from USSTATE where @USSTATE's name) set @USSTATE = 'A Lasca' - do this for each state? Arghh !!!  

etc.

, but I want to do it recursively, thanks for any help?

  UPDATE F SET F.USState = FRID to ASID F INNER SSF.USSCT = S . NOM  
.

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -