Click here to Skip to main content
15,904,494 members
Home / Discussions / Database
   

Database

 
GeneralRe: Query regarding SP's Pin
ParagGupta12-Sep-06 23:34
ParagGupta12-Sep-06 23:34 
QuestionQuestion abt self joined tables Pin
Rocky#12-Sep-06 20:04
Rocky#12-Sep-06 20:04 
AnswerRe: Question abt self joined tables Pin
Stephen McGuire13-Sep-06 12:14
Stephen McGuire13-Sep-06 12:14 
QuestionA question abt making the main page of DB application Pin
Rocky#12-Sep-06 20:00
Rocky#12-Sep-06 20:00 
QuestionMultiple Record Set Pin
Amit Kumar G12-Sep-06 14:20
Amit Kumar G12-Sep-06 14:20 
AnswerRe: Multiple Record Set Pin
Not Active13-Sep-06 3:20
mentorNot Active13-Sep-06 3:20 
QuestionUrgent Need Help....Rows to Columns Pin
Amit Kumar G12-Sep-06 8:53
Amit Kumar G12-Sep-06 8:53 
AnswerRe: Urgent Need Help....Rows to Columns Pin
Eric Dahlvang12-Sep-06 11:47
Eric Dahlvang12-Sep-06 11:47 
Too bad you can't use a cursor:

DECLARE @iColumns INT, @sql VARCHAR(2500),@cInstruction VARCHAR(50), @nInstruction int 

SET @sql = ''

DECLARE curInstructions CURSOR FOR SELECT DISTINCT InstructionDesc,InstructionID FROM TB_InstructionMaster
OPEN curInstructions
FETCH NEXT FROM curInstructions INTO @cInstruction,@nInstruction
WHILE @@FETCH_STATUS = 0
BEGIN
	SET @sql = @sql + ', (SELECT ''' + @cInstruction + ''' as fld 
                              FROM TB_ProductInstruction P2 
                              WHERE P2.ProductID = ProdInst.ProductID and InstructionID = ''' + 
                                    cast(@nInstruction as varchar) + ''') as [' + @cInstruction + ']'
	FETCH NEXT FROM curInstructions INTO @cInstruction,@nInstruction
END

close  curInstructions
DEALLOCATE curInstructions

SET @sql =  'SELECT distinct ProdMast.ProductID ' + @sql + ' 
FROM TB_ProductInstruction ProdInst 
right join tb_productmaster ProdMast on ProdInst.ProductID = ProdMast.ProductID'
exec(@sql)


--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters

QuestionSQL Join problem! Pin
richiemac12-Sep-06 3:21
richiemac12-Sep-06 3:21 
AnswerRe: SQL Join problem! Pin
Eric Dahlvang12-Sep-06 4:06
Eric Dahlvang12-Sep-06 4:06 
GeneralRe: SQL Join problem! Pin
richiemac12-Sep-06 5:05
richiemac12-Sep-06 5:05 
Questiondaynamic sql Pin
yazan_zahi12-Sep-06 2:10
yazan_zahi12-Sep-06 2:10 
AnswerRe: daynamic sql Pin
Amit Kumar G12-Sep-06 16:17
Amit Kumar G12-Sep-06 16:17 
Questionnulls in a DataTable Pin
hamidreza_buddy11-Sep-06 23:44
hamidreza_buddy11-Sep-06 23:44 
AnswerRe: nulls in a DataTable Pin
_AK_11-Sep-06 23:56
_AK_11-Sep-06 23:56 
AnswerRe: nulls in a DataTable Pin
albCode13-Sep-06 4:15
albCode13-Sep-06 4:15 
QuestionCode Error! Pin
Shahzad.Aslam11-Sep-06 23:18
Shahzad.Aslam11-Sep-06 23:18 
AnswerRe: Code Error! Pin
_AK_12-Sep-06 0:23
_AK_12-Sep-06 0:23 
QuestionAbout cursor in sqlserver 2000 Pin
yazan_zahi11-Sep-06 22:57
yazan_zahi11-Sep-06 22:57 
AnswerRe: About cursor in sqlserver 2000 Pin
Marek Grzenkowicz12-Sep-06 0:14
Marek Grzenkowicz12-Sep-06 0:14 
GeneralRe: About cursor in sqlserver 2000 Pin
Amit Kumar G12-Sep-06 16:23
Amit Kumar G12-Sep-06 16:23 
GeneralRe: Can I use Dynamic SQL in While Loop Pin
gopisant15-Apr-09 20:11
gopisant15-Apr-09 20:11 
Questionfetch data from table Pin
senthilmca11-Sep-06 19:21
senthilmca11-Sep-06 19:21 
AnswerRe: fetch data from table Pin
_AK_11-Sep-06 19:26
_AK_11-Sep-06 19:26 
AnswerRe: fetch data from table Pin
Amit Kumar G12-Sep-06 16:24
Amit Kumar G12-Sep-06 16:24 

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.