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)
 Sorting data dynamically

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-27 : 09:00:21
Michael Fong writes "Mu current coding in stored procedure is like this:

CREATE PROCEDURE [dbo].[locationIDColumn]

AS

begin transaction
select rowMany,
case when transport_id='S0600' then in_qty else '0' end as S0600,
case when transport_id='S0265' then in_qty else '0' end as S0265,

from dbo.tdum_win
where convert(varchar,create_time,20)='2004-04-20 07:00:04'
commit
GO

how to do dynamically when i have data stored in field location_id more than 50 and maybe will go up to 1000000++
The above statement is static which will only choose data which is in the value of S0600 and S0265. Its not that logic if i would write all the value in location_id out so that the outupt will look like this in SQL Query Analyser

rowMany S0600 S0265 ............................
--------- ------ ------- -------- -------- ---------
7892347 400 200


Thanx"

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-04-27 : 09:12:52
A search on dynamic cross-tab resulted.


[url]http://www.sqlteam.com/item.asp?ItemID=2955[/url]
Go to Top of Page
   

- Advertisement -