Click here to Skip to main content
12,355,050 members (40,512 online)
   

Database

 
JokeRe: Dynamic Query Question Pin
Mycroft Holmes16-Jul-11 13:06
memberMycroft Holmes16-Jul-11 13:06 
GeneralRe: Dynamic Query Question Pin
S Douglas11-Aug-11 9:48
memberS Douglas11-Aug-11 9:48 
GeneralRe: Dynamic Query Question Pin
PIEBALDconsult11-Aug-11 14:49
memberPIEBALDconsult11-Aug-11 14:49 
GeneralRe: Dynamic Query Question Pin
S Douglas12-Aug-11 4:48
memberS Douglas12-Aug-11 4:48 
GeneralRe: Dynamic Query Question Pin
PIEBALDconsult12-Aug-11 17:57
memberPIEBALDconsult12-Aug-11 17:57 
GeneralRe: Dynamic Query Question Pin
S Douglas13-Aug-11 8:20
memberS Douglas13-Aug-11 8:20 
GeneralRe: Dynamic Query Question Pin
PIEBALDconsult13-Aug-11 9:29
memberPIEBALDconsult13-Aug-11 9:29 
GeneralRe: Dynamic Query Question Pin
S Douglas13-Aug-11 22:30
memberS Douglas13-Aug-11 22:30 
GeneralRe: Dynamic Query Question Pin
PIEBALDconsult13-Aug-11 7:15
memberPIEBALDconsult13-Aug-11 7:15 
QuestionUPDATE Multiple tables on one filed. [modified] Pin
Member 808202113-Jul-11 11:12
memberMember 808202113-Jul-11 11:12 
AnswerRe: UPDATE Multiple tables on one filed. Pin
Blue_Boy13-Jul-11 23:29
memberBlue_Boy13-Jul-11 23:29 
AnswerRe: UPDATE Multiple tables on one filed. Pin
Shameel14-Jul-11 0:09
memberShameel14-Jul-11 0:09 
AnswerRe: UPDATE Multiple tables on one filed. Pin
smcnulty200014-Jul-11 22:39
membersmcnulty200014-Jul-11 22:39 
AnswerRe: UPDATE Multiple tables on one filed. [modified] Pin
Niladri_Biswas18-Jul-11 2:12
memberNiladri_Biswas18-Jul-11 2:12 
Hi, I am providing a solution to this problem but ideally you should follow as what Shameel has said..

Let us create 4 tables (one master and three child tables) as under

CREATE TABLE [dbo].[tblmaster](
	[testID] [varchar](50) NULL,
	[Name] [varchar](50) NULL
) ON [PRIMARY]
 

CREATE TABLE [dbo].[tblChild1](
	[testID] [varchar](50) NULL,
	[Name] [varchar](50) NULL,
	[Age] [int] NULL
) ON [PRIMARY]
 

CREATE TABLE [dbo].[tblChild2](
	[testID] [varchar](50) NULL,
	[Name] [varchar](50) NULL,
	[Address] [varchar](50) NULL
) ON [PRIMARY]
 
CREATE TABLE [dbo].[tblChild3](
	[testID] [varchar](50) NULL,
	[Sex] [varchar](6) NULL,
	[Address] [varchar](50) NULL,
	[Phone Number] [varchar](50) NULL
) ON [PRIMARY]
 
insert into tblmaster
select 's401', 'name10' union all
select 's402', 'name11' union all
select 's403', 'name12' union all
select 's404', 'name14'
 
insert into tblChild1 
select 's401', 'name20', 20 union all
select 's402', 'name21', 21 union all
select 's403', 'name22', 22 union all
select 's404', 'name23',23
 
insert into tblChild2 
select 's401', 'name30', 'address30' union all
select 's402', 'name31', 'address31' union all
select 's403', 'name32', 'address32' union all
select 's404', 'name33', 'address33' 
 
insert into tblChild3 
select 's401', 'male', 'address40','9885446789' union all
select 's402', 'female', 'address41','12345678' union all
select 's403', 'male', 'address42','34567891' union all
select 's404', 'female', 'address43','0986234' 
 
Select * from tblmaster
Select * from tblChild1
Select * from tblChild2
Select * from tblChild3

Now fire the below query

exec sp_msforeachtable N'
  IF EXISTS(SELECT 1 FROM sys.columns WHERE object_id=OBJECT_ID(''?'') AND name = ''testID'')
    EXEC (''UPDATE ? SET testID= case when testID = ''''s401'''' then ''''I00010'''' 
				      when testID = ''''s402'''' then ''''I00020'''' 
				      when testID = ''''s403'''' then ''''I00030'''' 
				      when testID = ''''s404'''' then ''''I00040'''' 
                                  end'')'
N.B.~
Use this example as a reference for your problem.

Thanks
Niladri Biswas
modified on Tuesday, July 19, 2011 5:48 AM

QuestionCalculate and display a progressive balance Pin
Rameez Raja11-Jul-11 20:48
memberRameez Raja11-Jul-11 20:48 
AnswerRe: Calculate and display a progressive balance Pin
djj5512-Jul-11 4:40
memberdjj5512-Jul-11 4:40 
AnswerRe: Calculate and display a progressive balance Pin
smcnulty200014-Jul-11 22:34
membersmcnulty200014-Jul-11 22:34 
GeneralRe: Calculate and display a progressive balance Pin
Rameez Raja16-Jul-11 22:49
memberRameez Raja16-Jul-11 22:49 
GeneralRe: Calculate and display a progressive balance Pin
smcnulty200018-Jul-11 13:36
membersmcnulty200018-Jul-11 13:36 
QuestionSelecting multiple columns from several tables without using JOIN Pin
DisIsHoody11-Jul-11 4:41
memberDisIsHoody11-Jul-11 4:41 
AnswerRe: Selecting multiple columns from several tables without using JOIN Pin
Blue_Boy11-Jul-11 4:55
memberBlue_Boy11-Jul-11 4:55 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
David Mujica11-Jul-11 5:28
memberDavid Mujica11-Jul-11 5:28 
AnswerRe: Selecting multiple columns from several tables without using JOIN Pin
kmoorevs11-Jul-11 10:08
memberkmoorevs11-Jul-11 10:08 
AnswerRe: Selecting multiple columns from several tables without using JOIN Pin
Shameel11-Jul-11 21:30
memberShameel11-Jul-11 21:30 
AnswerRe: Selecting multiple columns from several tables without using JOIN Pin
David Skelly12-Jul-11 3:54
memberDavid Skelly12-Jul-11 3:54 
AnswerRe: Selecting multiple columns from several tables without using JOIN Pin
AnnieMacD14-Jul-11 6:24
memberAnnieMacD14-Jul-11 6:24 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
Shameel14-Jul-11 18:52
memberShameel14-Jul-11 18:52 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
smcnulty200014-Jul-11 22:46
membersmcnulty200014-Jul-11 22:46 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
Shameel15-Jul-11 2:22
memberShameel15-Jul-11 2:22 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
AnnieMacD15-Jul-11 2:45
memberAnnieMacD15-Jul-11 2:45 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
Shameel15-Jul-11 7:50
memberShameel15-Jul-11 7:50 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
AnnieMacD15-Jul-11 7:56
memberAnnieMacD15-Jul-11 7:56 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
smcnulty200015-Jul-11 5:39
membersmcnulty200015-Jul-11 5:39 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
Shameel15-Jul-11 7:48
memberShameel15-Jul-11 7:48 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
smcnulty200015-Jul-11 8:08
membersmcnulty200015-Jul-11 8:08 
GeneralRe: Selecting multiple columns from several tables without using JOIN Pin
AnnieMacD15-Jul-11 2:44
memberAnnieMacD15-Jul-11 2:44 
AnswerRe: Selecting multiple columns from several tables without using JOIN Pin
smcnulty200014-Jul-11 23:20
membersmcnulty200014-Jul-11 23:20 
QuestionTemp and variable table cannot be created. Pin
nbgangsta10-Jul-11 22:27
membernbgangsta10-Jul-11 22:27 
AnswerRe: Temp and variable table cannot be created. Pin
Shameel11-Jul-11 1:42
memberShameel11-Jul-11 1:42 
AnswerRe: Temp and variable table cannot be created. Pin
DaveAuld11-Jul-11 2:57
mentorDaveAuld11-Jul-11 2:57 
AnswerRe: Temp and variable table cannot be created. Pin
djj5511-Jul-11 6:00
memberdjj5511-Jul-11 6:00 
AnswerRe: Temp and variable table cannot be created. Pin
S Douglas11-Aug-11 10:07
memberS Douglas11-Aug-11 10:07 
QuestionRestoration of publisher database to another system (merge replication) Pin
Abd.Jabbar9-Jul-11 21:39
memberAbd.Jabbar9-Jul-11 21:39 
AnswerRe: Restoration of publisher database to another system (merge replication) Pin
djj5511-Jul-11 3:28
memberdjj5511-Jul-11 3:28 
QuestionWho owns the data/database? Customer or vendor? Pin
kmoorevs9-Jul-11 5:55
memberkmoorevs9-Jul-11 5:55 
AnswerRe: Who owns the data/database? Customer or vendor? Pin
Mycroft Holmes9-Jul-11 13:13
memberMycroft Holmes9-Jul-11 13:13 
AnswerRe: Who owns the data/database? Customer or vendor? Pin
PIEBALDconsult10-Jul-11 6:32
memberPIEBALDconsult10-Jul-11 6:32 
GeneralRe: Who owns the data/database? Customer or vendor? Pin
kmoorevs11-Jul-11 9:14
memberkmoorevs11-Jul-11 9:14 
AnswerRe: Who owns the data/database? Customer or vendor? Pin
jschell12-Jul-11 11:08
memberjschell12-Jul-11 11:08 
GeneralRe: Who owns the data/database? Customer or vendor? Pin
kmoorevs13-Jul-11 5:03
memberkmoorevs13-Jul-11 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 27 Jun 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid