Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Complex Stored Procedure

Author  Topic 

ofsouto
Starting Member

22 Posts

Posted - 2005-01-26 : 13:47:35
Hi, dear

I have 2 tables: tbClassified, tbNotClassified.

CREATE TABLE [dbo].[ tbClassified] (
[Suplier_Code] [char] (8),
[Ref_date] [smalldatetime] NOT NULL ,
[Risc_Type] [char] (1),
[Client_Code] [char] (8),
[Risc_level] [char] (4),
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[ tbClassified] ADD
CONSTRAINT [PK_TBCLASSIFIED] PRIMARY KEY NONCLUSTERED
(
[Suplier_Code],
[Ref_date],
[Risc_Type]
)
GO

CREATE TABLE [dbo].[ tbNotClassified] (
[Suplier_Code] [char] (8),
[Ref_date] [smalldatetime] NOT NULL ,
[Risc_Type] [char] (1),
[Client_Code] [char] (8),
[Risc_level] [char] (4),
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[ tbClassified] ADD
CONSTRAINT [PK_TBNOTCLASSIFIED] PRIMARY KEY NONCLUSTERED
(
[Suplier_Code],
[Ref_date],
[Risc_Type]
)
GO

These tables are differents but I just list the common attributes.

I need to show the level evolution of each client during the last 13 months (Now and the last 12 months). I intend to create a grid as showed bellow:

Months Jan/2005 Dec/2004 ... Mar/2004 Feb/2004 Jan/2004
Clients
00001 01 02 05 06 07
00002 NC NC NC NC NC
00003 05 05 05 05 05
...
00008 NC 01 06 04 NC
00009 07 06 03 02 01
00010 NC NC 01 01 NC

What's the best and fastest way to create a Stored Procedure to list this grid? Temporary Tables? Cursors?

Thank you very much

Obede
Brazil

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-26 : 13:50:58
probably this:
http://www.sqlteam.com/item.asp?ItemID=2955

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -