x002548's Blog
Not Just a Number - Brett Kaiser
Site Sections
Home
Contact
Syndication
Login
Posts
83
Comments
600
Trackbacks
40
<< Because you're mine, I walk the line
|
Home
How can I update Multiple Tables at once
"CAN'T BE DONE" -- Crazy boy
Well at first glance, that may very well be the answer, as in this thread:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=100207
Now, this might not be what the OP is looking for, but if you employ a partitioned view, then yes, it's doable
cut and paste the sample code to see it in action
USE Northwind
GO
CREATE TABLE myTable99 (Col1 int PRIMARY KEY CHECK (Col1 BETWEEN 1 AND 10), Col2 varchar(50))
CREATE TABLE myTable98 (Col1 int PRIMARY KEY CHECK (Col1 BETWEEN 11 AND 20), Col2 varchar(50))
GO
INSERT INTO myTable99(Col1, Col2)
SELECT 1, 'x' UNION ALL
SELECT 2, 'y' UNION ALL
SELECT 3, 'z'
INSERT INTO myTable98(Col1, Col2)
SELECT 11, 'x' UNION ALL
SELECT 12, 'y' UNION ALL
SELECT 13, 'z'
GO
CREATE VIEW myView99
AS
SELECT Col1, Col2 FROM myTable99
UNION ALL
SELECT Col1, Col2 FROM myTable98
GO
SELECT * FROM myView99
UPDATE myView99 SET Col2 = 'x002548' WHERE Col2 = 'z'
SELECT * FROM myView99
/*
DROP VIEW myView99
DROP TABLE myTable99, myTable98
*/
posted on Thursday, April 03, 2008 9:49 AM
Print
Comments
#
re: How can I update Multiple Tables at once
Tal Olier
4/14/2008 3:05 AM
you can also use trigger...
#
re: How can I update Multiple Tables at once
narayanan
4/16/2008 5:22 AM
hey what do u mean to say update multiple tables at once do u want to update the same thing into two tables
or different values in different tables
#
Meaning of Trigger,GO,AS,ON
Ashtu
4/16/2008 6:19 AM
Full Explaination of Trigger,ON,AS function,Droptable
#
How can I drop Multiple Tables at once
sanjana
5/13/2008 9:45 AM
Please if u can help on drop on sql 2k
Comments have been closed on this topic.
Article Categories
DB2
West Orange Ridership Community
Archives
April, 2008 (1)
July, 2007 (1)
March, 2007 (2)
February, 2007 (4)
December, 2006 (1)
November, 2006 (2)
September, 2006 (4)
August, 2006 (2)
July, 2006 (2)
June, 2006 (3)
May, 2006 (2)
November, 2005 (1)
October, 2005 (1)
September, 2005 (1)
August, 2005 (2)
June, 2005 (8)
May, 2005 (6)
April, 2005 (5)
February, 2005 (4)
January, 2005 (5)
December, 2004 (2)
October, 2004 (2)
September, 2004 (2)
August, 2004 (1)
June, 2004 (6)
May, 2004 (2)
April, 2004 (2)
March, 2004 (2)
February, 2004 (3)
January, 2004 (2)
October, 2003 (1)
September, 2003 (1)
Post Categories
Code Generataion
DB2
Disconnected Ramblings
Oracle
SQL Gimmicks
SQL Server
Image Galleries
Directions
Lost Again?
Misc
Mountains
SQLSki Team
Misc
It's an Enigma Wrapped up in a riddle
Little Feat
Radio 'Rita
Ski Resort Cam List
SQL Server
Daily WTF (Doesn't mean World Tennis Federation)
dbForums Member List
SQL Express Team's BLOG
SQL Server 2000 Books Online
SQLTeam
SQLTeam Member List
Copyright © 2005 Brett Kaiser (x002548)
This work is licensed under a
Creative Commons License