Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to do Seek in SQL query?
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01447540
Message ID:
01447546
Vues:
41
>>Hi,
>>
>>I am trying to update a column of one table based on the value in another table. I could write a little VFP program to do it but I want to learn to do it in T-SQL. Here is what I want to do:
>>
>>Table1 has column UserID nchar(8) and UserPk int.
>>Table2 has column UserID nchar(8) and UserPk int. The column UserPk has only 0 (zero). I want to update the entry in column UserPk of Table2 based on matching row (by UserID) in Table1.
>>
>>How do you do it in T-SQL?
>
>Same as you do in VFP
>
>UPDATE T1 set UserPK = T2.UserPK  from Table1 T1 INNER JOIN Table2 T2 on T1.UserID = T2.UserID where T1.UserPK = 0
Thank you. Actually I would probably do it a "long" way in VFP using a .PRG procedure with SEEK(). Your approach is much better.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform