Click here to Skip to main content
       

Database

 
GeneralRe: SQL 2008 Truncate vs Delete PinmvpEddy Vluggen12-Feb-13 9:36 
GeneralRe: SQL 2008 Truncate vs Delete PinmemberKhorshed Alam, Dhaka18-Feb-13 19:09 
AnswerRe: SQL 2008 Truncate vs Delete PinmemberNickPace12-Feb-13 11:09 
AnswerRe: SQL 2008 Truncate vs Delete Pinmemberdjj5513-Feb-13 4:59 
AnswerRe: SQL 2008 Truncate vs Delete Pinmembergvprabu20-Feb-13 22:37 
QuestionSQL Server 2008 PinmemberVishwaKL10-Feb-13 18:51 
AnswerRe: SQL Server 2008 PinmemberShameel10-Feb-13 23:33 
AnswerRe: SQL Server 2008 Pinmemberjschell11-Feb-13 9:20 
Questionupdate values in a table in single query Pinmembernainakarri7-Feb-13 21:07 
AnswerRe: update values in a table in single query PinmemberMycroft Holmes7-Feb-13 22:00 
GeneralRe: update values in a table in single query PinmemberShameel10-Feb-13 23:38 
GeneralRe: update values in a table in single query PinmemberMycroft Holmes11-Feb-13 14:30 
AnswerRe: update values in a table in single query PinmvpEddy Vluggen7-Feb-13 23:42 
GeneralRe: update values in a table in single query Pinmembergvprabu10-Feb-13 19:02 
-- Multiple Update using Joins

-- Create temp table for Teste Update Statement
CREATE TABLE EmpDtls(Code VARCHAR(10), Name VARCHAR(100), DeptCode TINYINT)
CREATE TABLE DeptDtls(DeptCode TINYINT, DeptName VARCHAR(50), EmpCount INT)
 
-- Insert Sample Values
INSERT INTO EmpDtls(Code, Name, DeptCode)
VALUES('Emp1','Venkat', 1), ('Emp2','Prabu', 2), ('Emp3','Kumar', 1), ('Emp4','Karthick', 3),
('Emp5','Amith', 2),('Emp6','HariKrishna', 2)
 
INSERT INTO DeptDtls(DeptCode, DeptName)
VALUES(1, 'IT'),(2, 'Sales'), (3,'HR'), (4, 'Accounts')
 
-- Check the sample values
SELECT Code, Name, DeptCode FROM EmpDtls
SELECT DeptCode, DeptName,EmpCount FROM DeptDtls
 
-- Update Employees Count
UPDATE D SET D.EmpCount= E.EmpCount
FROM DeptDtls D
INNER JOIN (SELECT DeptCode, COUNT(Code) 'EmpCount' FROM EmpDtls GROUP BY DeptCode) E ON E.DeptCode=D.DeptCode
 
SELECT DeptCode, DeptName,EmpCount FROM DeptDtls
 
-- Drop Table 
IF OBJECT_ID('EmpDtls') IS NOT NULL DROP TABLE EmpDtls
IF OBJECT_ID('DeptDtls') IS NOT NULL DROP TABLE DeptDtls

AnswerRe: update values in a table in single query Pinmembergvprabu20-Feb-13 22:43 
QuestionIs it possible to print a variable in stored procedure PinmemberDeepthi.214567-Feb-13 20:45 
AnswerRe: Is it possible to print a variable in stored procedure Pinmembernainakarri7-Feb-13 21:22 
GeneralRe: Is it possible to print a variable in stored procedure Pinmembervanikanc12-Feb-13 9:19 
QuestionVisual Studio 2005 Access 2010 Database PinmemberMember 98194707-Feb-13 13:06 
AnswerRe: Visual Studio 2005 Access 2010 Database PinmemberMycroft Holmes7-Feb-13 14:45 
QuestionSimulate transaction: non blocking insert / update PinmemberBob Stanneveld7-Feb-13 12:12 
AnswerRe: Simulate transaction: non blocking insert / update PinmemberMycroft Holmes7-Feb-13 14:44 
QuestionPropagating a MySQL transaction with MSMQ II PinmemberGer Hayden6-Feb-13 9:08 
QuestionMissing Data in an Access Report PinmemberVuyiswa Maseko6-Feb-13 4:03 
AnswerRe: Missing Data in an Access Report Pinmemberjschell6-Feb-13 9:11 
GeneralRe: Missing Data in an Access Report PinmemberVuyiswa Maseko6-Feb-13 20:01 
GeneralRe: Missing Data in an Access Report Pinmemberjschell7-Feb-13 10:52 
AnswerRe: Missing Data in an Access Report PinmemberMycroft Holmes6-Feb-13 13:27 
GeneralRe: Missing Data in an Access Report PinmemberVuyiswa Maseko6-Feb-13 20:06 
GeneralRe: Missing Data in an Access Report PinmemberMycroft Holmes6-Feb-13 21:27 
GeneralRe: Missing Data in an Access Report PinmemberVuyiswa Maseko6-Feb-13 21:32 
GeneralRe: Missing Data in an Access Report Pinmemberjschell7-Feb-13 10:56 
Questionoracle error with winserver2008 Pinmemberfares35-Feb-13 2:03 
AnswerRe: oracle error with winserver2008 PinmemberBernhard Hiller5-Feb-13 5:57 
Questionchar(255) vs varchar(255) vs varchar(MAX) Pinmemberdevvvy1-Feb-13 19:22 
AnswerRe: char(255) vs varchar(255) vs varchar(MAX) PinmvpRichard MacCutchan2-Feb-13 0:07 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) [modified] Pinmemberdevvvy2-Feb-13 16:39 
AnswerRe: char(255) vs varchar(255) vs varchar(MAX) PinmemberPIEBALDconsult2-Feb-13 6:22 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) Pinmemberdevvvy3-Feb-13 0:30 
GeneralRe: char(255) vs varchar(255) vs varchar(MAX) Pinmemberjschell3-Feb-13 7:36 
QuestionSP Unexpected Behavior Pinmembereddieangel1-Feb-13 8:19 
QuestionEncrypt a field in the database. Pinmembervanikanc1-Feb-13 6:31 
AnswerRe: Encrypt a field in the database. PinmvpEddy Vluggen1-Feb-13 8:02 
Questioncheck before insert Pinmembervanikanc31-Jan-13 5:55 
AnswerRe: check before insert PinmvpEddy Vluggen31-Jan-13 6:00 
GeneralRe: check before insert PinmvpEddy Vluggen31-Jan-13 11:35 
AnswerRe: check before insert Pinmembermark merrens31-Jan-13 9:10 
GeneralRe: check before insert Pinmembervanikanc31-Jan-13 9:21 
GeneralRe: check before insert Pinmembermark merrens31-Jan-13 11:09 
GeneralRe: check before insert PinmemberChris Meech31-Jan-13 11:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web04 | 2.8.141223.1 | Last Updated 26 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid