Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2006, 07:31 AM
Authorized User
 
Join Date: Aug 2003
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default update query

I need a update query.
Please dont go by the normalizaton, as the situation explained below has reduntant data.

Table : "users"
Columns: "username", "userid"
userid is primary key

Table : "records"
Columns: "recordid", "username", "userid"
recordid is primary key
userid is foreignkey


The "records" table has few records which have fixed hard coded text say "abc" in the "username" field.

I want to update the incorrect "username" in "records" table with the correct ones; i.e. fetch them from users and update in "records" table, without using cursor.


Regards,

Vinay



 
Old February 28th, 2006, 09:55 AM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You don't need a cursor. Some like:

Update records set username = users.username FROM users, records WHERE users.userid = records.userid

Scott






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Query Help dalezjc Classic ASP Basics 8 March 18th, 2008 08:49 AM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Update query trab Access 1 May 11th, 2006 03:58 PM
Please Help me about UPDATE query huyremy VB Databases Basics 8 September 29th, 2004 03:45 AM
Update query edcaru Access 3 June 14th, 2004 03:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.