Click here to Skip to main content
15,918,976 members
Home / Discussions / Database
   

Database

 
AnswerRe: Can anyone explain me this code Pin
Colin Angus Mackay11-Aug-07 8:40
Colin Angus Mackay11-Aug-07 8:40 
GeneralRe: Can anyone explain me this code Pin
NetBot11-Aug-07 10:03
NetBot11-Aug-07 10:03 
AnswerRe: Can anyone explain me this code Pin
Colin Angus Mackay11-Aug-07 10:15
Colin Angus Mackay11-Aug-07 10:15 
AnswerRe: Can anyone explain me this code Pin
negli11-Aug-07 14:27
negli11-Aug-07 14:27 
GeneralRe: Can anyone explain me this code Pin
Colin Angus Mackay12-Aug-07 3:46
Colin Angus Mackay12-Aug-07 3:46 
AnswerRe: Can anyone explain me this code Pin
Rami Said Abd Alhalim11-Aug-07 22:37
Rami Said Abd Alhalim11-Aug-07 22:37 
QuestionSQL Query Prob Pin
Amit Kumar G11-Aug-07 2:14
Amit Kumar G11-Aug-07 2:14 
AnswerRe: SQL Query Prob Pin
Krish - KP12-Aug-07 18:23
Krish - KP12-Aug-07 18:23 
With simple query is not possible. however check this

SET NOCOUNT ON
DECLARE @T1_id AS Int
DECLARE @T1_Name AS Varchar(10)
DECLARE @T2_id AS Int
DECLARE @T2_Reason AS Varchar(5)
DECLARE @qryResult AS Varchar(256)
DECLARE @cnt AS Smallint

IF NOT EXISTS(SELECT * FROM tempdb..sysobjects WHERE name LIKE '#T3[_]%') 
				CREATE TABLE #T3(id int, Name varchar(10), Reason1 varchar(5), 
				Reason2 varchar(5), Reason3 varchar(5), Reason4 varchar(5))varchar(5), Reason4 varchar(5))
DELETE FROM #T3

DECLARE CurT1 CURSOR FOR SELECT * FROM #t1
OPEN CurT1
FETCH CurT1 INTO @T1_id, @T1_Name
WHILE @@FETCH_STATUS = 0
BEGIN
	INSERT INTO #T3 (id, Name) VALUES(@T1_id, @T1_Name)
	SET @cnt = 0

	DECLARE CurT2 CURSOR FOR SELECT * FROM #t2 WHERE id = @T1_id
	OPEN CurT2
	FETCH CurT2 INTO @T2_id, @T2_Reason
	WHILE @@FETCH_STATUS = 0
	BEGIN
		SET @cnt = @cnt + 1
		SET @qryResult =  'UPDATE #T3 SET Reason' + Cast(@cnt AS Varchar(10)) + ' = ''' 
			+ @T2_Reason + ''' WHERE id = ' + Cast(@T1_id As Varchar(5))
		EXEC (@qryResult)
		FETCH CurT2 INTO @T2_id, @T2_Reason
	END
	CLOSE CurT2
	DEALLOCATE CurT2
	FETCH CurT1 INTO @T1_id, @T1_Name
END
CLOSE CurT1
DEALLOCATE CurT1
SET NOCOUNT OFF
SELECT * FROM #T3
--SELECT * FROM #T1
--SELECT * FROM #T2

/*
CREATE TABLE #T1(id int,Name varchar(10))
insert into #T1 (id,Name) values (1,'Shon')
insert into #T1 (id,Name) values (2,'Julie')

CREATE TABLE #T2(id int,Reason varchar(5))
insert into #T2 (id,Reason) values (1,'X')
insert into #T2 (id,Reason) values (2,'Y')
insert into #T2 (id,Reason) values (1,'Z')
insert into #T2 (id,Reason) values (1,'K')
*/




Regards
KP

QuestionMS SQL 2005 Pin
raneesh c10-Aug-07 21:35
raneesh c10-Aug-07 21:35 
AnswerRe: MS SQL 2005 Pin
Paul Conrad11-Aug-07 4:46
professionalPaul Conrad11-Aug-07 4:46 
QuestionGrouping Problem In SQL Server Pin
R.S.Hegde10-Aug-07 20:01
R.S.Hegde10-Aug-07 20:01 
AnswerRe: Grouping Problem In SQL Server Pin
Rami Said Abd Alhalim10-Aug-07 21:38
Rami Said Abd Alhalim10-Aug-07 21:38 
AnswerSenthil' S reply for Grouping Problem In SQL Server Pin
Senthil S10-Aug-07 21:54
Senthil S10-Aug-07 21:54 
QuestionHow to auto generate custom Id value..., Pin
Member 387988110-Aug-07 18:41
Member 387988110-Aug-07 18:41 
AnswerSenthil'S Reply How to auto generate custom Id value..., Pin
Senthil S10-Aug-07 21:02
Senthil S10-Aug-07 21:02 
AnswerRe: How to auto generate custom Id value..., Pin
Rami Said Abd Alhalim10-Aug-07 22:07
Rami Said Abd Alhalim10-Aug-07 22:07 
Question[ADO.NET/C#] result of a function Pin
Mwambe10-Aug-07 3:36
Mwambe10-Aug-07 3:36 
AnswerRe: [ADO.NET/C#] result of a function Pin
R. Giskard Reventlov10-Aug-07 3:50
R. Giskard Reventlov10-Aug-07 3:50 
AnswerRe: [ADO.NET/C#] result of a function Pin
Rami Said Abd Alhalim10-Aug-07 22:55
Rami Said Abd Alhalim10-Aug-07 22:55 
QuestionThe highest value for VarBinary(MAX) in Production Server Pin
Nadia Monalisa10-Aug-07 1:53
Nadia Monalisa10-Aug-07 1:53 
AnswerRe: The highest value for VarBinary(MAX) in Production Server Pin
Talal Sultan10-Aug-07 2:01
Talal Sultan10-Aug-07 2:01 
GeneralRe: The highest value for VarBinary(MAX) in Production Server Pin
Nadia Monalisa10-Aug-07 2:10
Nadia Monalisa10-Aug-07 2:10 
GeneralRe: The highest value for VarBinary(MAX) in Production Server Pin
Talal Sultan10-Aug-07 2:16
Talal Sultan10-Aug-07 2:16 
GeneralRe: The highest value for VarBinary(MAX) in Production Server Pin
Luis Alonso Ramos12-Aug-07 14:49
Luis Alonso Ramos12-Aug-07 14:49 
Questionhow can i write a query.... Pin
koolprasad200310-Aug-07 0:06
professionalkoolprasad200310-Aug-07 0:06 

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.