Pivoting A Recordset

Nov 12, 2004

I have a reference table that looks like this

id | value
==========
1,abc
1,def
1,ghi
2,def
2,jkl

I want these values to go horizontally into another table matched on id, to look like this:

id | value
========
1,abc def ghi
2, def jkl

I built a cursor to parse through it but was taking forever (there's 185,000 records in the reference table). Any idea's on the fastest way to perform this function?

View 1 Replies


ADVERTISEMENT

Pivoting

Sep 21, 2007

hello guys !!!

i have a table as

id date data
1 3/10/2007 "hello"
1 4/10/2007 "hi"
2 3/10/2007 "hello"
2 4/10/2007 "why"


i need the output like

id 3/10/2007 4/10/2007
1 "hello" "hi"
2 "hello" "why"


Any idea ???
any means to do it??

View 5 Replies View Related

Pivoting

May 7, 2008



Hi ,


My source file looks like this.








Month

Mar-07
Apr-07
May-07







Non-Accruals

$304,732,515
$307,051,978
$308,274,921

REO

$115,072,839
$123,957,394
$149,744,174

Home Equity Total NPA

$419,805,354
$431,009,372
$458,019,095


Destination table should look like this.










Month
HE Non-Accruals
HE REO
Home Equity Total NPA

Mar-07
$ 304,732,515
$ 115,072,839
$ 419,805,354

Apr-07
$ 307,051,978
$ 123,957,394
$ 431,009,372

May-07
$ 308,274,921
$ 149,744,174
$ 458,019,095



Can anyone help me to write t-sql code to transfer data into destination table as its shown above.
Thanks

View 1 Replies View Related

Pivoting A CTE

Apr 25, 2008



I've done both a CTE and a pivot, but never together. I did see a few examples out there and followed them, but mine isn't working. I have four 'tables' within the CTE, and then my final select statement joins all of them and attempts to pivot. My error is:


Msg 156, Level 15, State 1, Line 90

Incorrect syntax near the keyword 'PIVOT'.



WITH TwoYrsActual (LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,Week_Idx, LocationType_Code, Scenario_Idx, Scenario_Code, PlannedSalesAmtUSD,"06Actual")

AS (

SELECT DISTINCT LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,His.Week_Idx AS 'Week_Idx', His.LocationType_Code AS 'LocationType_Code', His.Scenario_Idx AS 'Scenario_Idx', Scenario_Code, PlannedSalesAmtUSD,

ActualSalesAmtUSD AS '06Actual'

FROM dbo.FactInventoryHistory HIS

INNER JOIN DimLocation LOC ON

His.LocationType_Code = Loc.LocationType_Code

INNER JOIN DimDate Date ON

His.Week_idx = Date.Date_Idx

INNER JOIN DimScenario Scenario ON

His.Scenario_Idx = Scenario.Scenario_Idx

WHERE Scenario_Code = 'FY06A'

GROUP BY LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,His.Week_Idx, His.LocationType_Code, His.Scenario_Idx, Scenario_Code, PlannedSalesAmtUSD,

ActualSalesAmtUSD

),

OneYearActual (LocationType_Name, FiscalYear_Name,FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,Week_Idx, LocationType_Code, Scenario_Idx, Scenario_Code, PlannedSalesAmtUSD,

"07Actual")

AS (

SELECT DISTINCT LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,His.Week_Idx AS 'Week_Idx', His.LocationType_Code AS 'LocationType_Code', His.Scenario_Idx AS 'Scenario_Idx', Scenario_Code, PlannedSalesAmtUSD,

ActualSalesAmtUSD AS '07Actual'

FROM dbo.FactInventoryHistory HIS

INNER JOIN DimLocation LOC ON

His.LocationType_Code = Loc.LocationType_Code

INNER JOIN DimDate Date ON

His.Week_idx = Date.Date_Idx

INNER JOIN DimScenario Scenario ON

His.Scenario_Idx = Scenario.Scenario_Idx

WHERE Scenario_Code = 'FY07A'

GROUP BY LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,His.Week_Idx, His.LocationType_Code, His.Scenario_Idx, Scenario_Code, PlannedSalesAmtUSD,

ActualSalesAmtUSD

),

PresentYrActual (LocationType_Name,FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,Week_Idx, LocationType_Code, Scenario_Idx, Scenario_Code, PlannedSalesAmtUSD,

"08Actual")

AS (

SELECT LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,His.Week_Idx AS 'Week_Idx', His.LocationType_Code AS 'LocationType_Code', His.Scenario_Idx AS 'Scenario_Idx', Scenario_Code, PlannedSalesAmtUSD,

ActualSalesAmtUSD AS '08Actual'

FROM dbo.FactInventoryHistory HIS

INNER JOIN DimLocation LOC ON

His.LocationType_Code = Loc.LocationType_Code

INNER JOIN DimDate Date ON

His.Week_idx = Date.Date_Idx

INNER JOIN DimScenario Scenario ON

His.Scenario_Idx = Scenario.Scenario_Idx

WHERE Scenario_Code = 'FY08A'

GROUP BY LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,His.Week_Idx, His.LocationType_Code, His.Scenario_Idx, Scenario_Code, PlannedSalesAmtUSD,

ActualSalesAmtUSD

),





PresentYrPlanned (LocationType_Name,FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,Week_Idx, LocationType_Code, Scenario_Idx, Scenario_Code, PlannedTY,

ActualSalesAmtUSD)

AS (

SELECT LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,His.Week_Idx AS 'Week_Idx', His.LocationType_Code AS 'LocationType_Code', His.Scenario_Idx AS 'Scenario_Idx', Scenario_Code, PlannedSalesAmtUSD AS PlannedTY,

ActualSalesAmtUSD

FROM dbo.FactInventoryHistory HIS

INNER JOIN DimLocation LOC ON

His.LocationType_Code = Loc.LocationType_Code

INNER JOIN DimDate Date ON

His.Week_idx = Date.Date_Idx

INNER JOIN DimScenario Scenario ON

His.Scenario_Idx = Scenario.Scenario_Idx

WHERE Scenario_Code = 'FY08P'

GROUP BY LocationType_Name, FiscalYear_Name, FiscalPeriodOfYear, FiscalWeekOfPeriod, FiscalWeekOfYear,His.Week_Idx, His.LocationType_Code, His.Scenario_Idx, Scenario_Code, PlannedSalesAmtUSD,

ActualSalesAmtUSD

)





select * from (

SELECT PresentYrActual.LocationType_Name, PresentYrActual.FiscalPeriodOfYear, PresentYrActual.FiscalWeekOfPeriod, PresentYrActual.FiscalWeekOfYear, PresentYrActual.LocationType_Code, PresentYrActual.Scenario_Idx, PresentYrActual.Scenario_Code, "08Actual", "07Actual", "06Actual",PlannedTY

FROM PresentYrActual

FULL OUTER JOIN OneYearActual ON

PresentYrActual.FiscalWeekOfYear = OneYearActual.FiscalWeekOfYear AND

PresentYrActual.LocationType_Code = OneYearActual.LocationType_Code

FULL OUTER JOIN TwoYrsActual ON

PresentYrActual.FiscalWeekOfYear = TwoYrsActual.FiscalWeekOfYear AND

PresentYrActual.LocationType_Code = TwoYrsActual.LocationType_Code

FULL OUTER JOIN PresentYrPlanned ON

PresentYrActual.FiscalWeekOfYear = PresentYrPlanned.FiscalWeekOfYear AND

PresentYrActual.LocationType_Code = PresentYrPlanned.LocationType_Code

)

PIVOT

(

SUM(PlannedTY)

FOR PresentYrActual.LocationType_Code IN (C, M))

AS pivottable

View 13 Replies View Related

Getting Nulls When Pivoting

Aug 29, 2013

I'm getting nulls on execution of the below query. I have tried both isnull and coalesce, but to no avail.

select *
from
(
select
a.BusinessUnitCode,
a.AdmitCCYYMM As Date, a.[Count of Admits]*1.0 / m.MemberCount * 12000 AdmitsPer1000

[Code] .....

View 3 Replies View Related

Related To Pivoting

Jan 4, 2006

there is a prblem with data in pivoting the table.
problem is like this--

there is some data 'xy' and some data 'xy '. when i m giving 'xy' as a pivot key value it doesent recognise 'xy ' and viseversa..

i can't reduce the size of the datatype coz there is some data of diffrent size as 'abcd'.

this data is loaded from excel sheet to sql sever table.

wht can i do for this problem.

is there any method to truncate the indivisual data, i m using nvarchar datatype for this.

View 2 Replies View Related

Pivoting Query On T-sql

Jul 20, 2005

gud day.please help me. im working right now on a case study that willretrieve/produce a simple report on sql. my problem is I dont know howto pivot queries like in access. please help me. thanks

View 2 Replies View Related

Pivoting Table

Jan 28, 2008



Hello there I have a table like so

Q1 Q2 Q3 Q4 Sales Rep
1 5 6 0 John

2 3 6 0 Rod
3 2 3 0 Gill
4 5 1 0 Guy



And I would like to rearrange it like

John Rod Gill Guy
Q1
Q2
Q3
Q4



Is this something I can accomplish with the PIVOT or UNPIVOT commands? Is there another way?

View 9 Replies View Related

Pivoting A Table

May 7, 2008



Hi ,

I want to pull data from XLs file and put them in a table.

Source file looks like this.








Month

Mar-07
Apr-07
May-07







Non-Accruals

$304,732,515
$307,051,978
$308,274,921

REO

$115,072,839
$123,957,394
$149,744,174

Home Equity Total NPA

$419,805,354
$431,009,372
$458,019,095


Destination table should look like this.
Date(Only the first row ) in XL file is in the following format.
DATE(YEAR($O1)-1,MONTH($O1)-1,DAY($O1)).
From second row onwords data format is Money type.
I hope I need to convert the date row into SQL datetime type too. Otherwise it comes as NULL.










Month
Non-Accruals
REO
Home Equity Total NPA

Mar-07
$ 304,732,515
$ 115,072,839
$ 419,805,354

Apr-07
$ 307,051,978
$ 123,957,394
$ 431,009,372

May-07
$ 308,274,921
$ 149,744,174
$ 458,019,095



Can i create a SSIS package to do this job? if so , How? I'm not sure which transformation should i used and how?
Hope some one can help me

Thanks

View 5 Replies View Related

Pivoting Data

Apr 28, 2008


Hi,

Can anybody help me with the following...I want to Pivot the following data






Pcode
Year
Month
Mcode
Value



2
2008
March
EN10A
56349.1



2
2008
March
EN10B
1061.6



2
2008
March
EN10C
2.67



2
2008
March
EN10D
8370



2
2008
April
EN10A
819.31



2
2008
April
EN10B
245.09



2
2008
April
EN10C
33.38



2
2008
April
EN10D
2.31



























After Pivot...the data should be like this






















Pcode
Year
Month
EN10A
EN10B
EN10C
EN10D

2
2008
March
56349.1
1061.6
2.67
8370

2
2008
April
819.31
245.09
33.38
2.31



Can we use Pivot function or is their a easier way for doing this...Also the MCodes are dynamic so now there are only 4 distinct MCodes but they may be more than four...

View 4 Replies View Related

Pivoting Row Values Into Colums

Oct 11, 2004

I’d like to get some data which includes month values bound to a data grid. The data is stored in a table like so:

Measure Month Value
A June 10.00
A July 9.00
A Aug 11.00
B Jun 100.00
B Jul 98.00
B Aug 99.00
C Jun 0.75
C Jul 0.8
C Aug 0.91

I need to report the data like this:
Measure Jun Jul August
A 10 9 11
B 100 98 99
C 75% 80% 91%

This was simple in classic ASP. Just use two recordsets, create a new table cell for each month using the first recordset then use the second recordset for each row.

But is there a way to “Pivot� or rotate the data so I can use the DataGrid? It only seems possible if each month has its own column field in table. Each month add a new column.

I can restructure the database, if needed.

I thought about creating a Cube, but that seems to have its own limitations. For example what if I want to add a Column for Quarter and year totals? I don’t think it’s possible to show multiple planes like that in an query of a cube.

It seems that this might be resolved in the presentation layer or the data layer. Any Suggestions?

View 1 Replies View Related

How To Set Null Values To Zero When Pivoting

Jun 4, 2008

I have a table with the following structure

[ID] [A] [B] [Cnt] [Qty]
1 s v1 4 40
2 g v1 2 23
3 p v2 7 22
4 l v3 1 6
5 v v4 7 5


Since I do not know before hand what [B] will be , I have created a dynamic script to pivot the data :


Select *
from ( select [ID],[A],[B],sum([Cnt]) AS Cnt
group by [ID],[A],[B]
) a
PIVOT ( sum(cnt) for [B] in (@list)) b


Now thequstion is :
1. How do I amend this qry to eliminate nulls in my output
[ID] [A] [v1] [v2] ......[vn]
1 s null 9
2 g 10 null


2. Is it possible to include both [cnt] and [Qty] traspose along
[B] = v1,v2 ...... vn


Any advice will be most welcome.

Thanks

View 4 Replies View Related

SQL Server 2000 - PIVOTING

Nov 29, 2007

I need some help here in Pivoting the table.
I have the table with the Following Columns.. and here is the sample data. Assume that below table will just have one weeks worth of data.

I can write a stored Proc using cursor, but I just want to learn how
to do it with using cursors

TD-------- Acct------ RouteID----Symbol---- Quantity----
---------- ---------- ---------- ---------- -----------
11/26/2007 40B91209-- CSFB------ GBL--------100
11/26/2007 40B91209-- SIGMA-X----TDY--------100
11/26/2007 4W3L1209-- CSFB------ BIDZ------ 1300
11/26/2007 4W3L1209-- CSFB------ SURW------ 100
11/27/2007 HFS10003-- SIGMA-X----URBN------ 500
11/27/2007 RAM10001-- ISE--------DSCP------ 300
11/27/2007 RAM10001-- SIGMA-X----HYC--------468
11/28/2007 HFS10003-- CSFB------ ARO--------5900
11/28/2007 HFS10003-- CSFB------ CAB--------1300
11/28/2007 HFS10003-- CSFB------ PNRA------ 4600
11/29/2007 RAM10001-- CSFB------ DSCP------ 175
11/29/2007 HFS10003-- CSFB------ CL-------- 220
11/29/2007 WIL10008-- SIGMA-X----CBM--------1400


The output should look some thing like this. If some can help me

AcctNum----RouteID--symbol--MON--TUE--Wed--THU---- FRI
WIL10008---SIGMA-X--CBM-----0----0----0----1400-- 0

Thanks for any help.

View 2 Replies View Related

Pivoting Data Works In One Db But Not Another

Mar 20, 2008

In the following code examples I got to learn PIVOT, I found an error for SUM. However when this is ran against the AdventureWorks db it works fine. Notice it is using a table variable and not an actual table. What do I need to do to my db to get this to work?

Thanks!




declare @sales table
(
[Year] int,
Quarter char(2),
Amount float
)

insert into @sales values(2001, 'Q1', 70)
insert into @sales values(2001, 'Q1', 150)
insert into @sales values(2002, 'Q1', 20)
insert into @sales values(2001, 'Q2', 15)
insert into @sales values(2002, 'Q2', 25)
insert into @sales values(2001, 'Q3', 50)
insert into @sales values(2002, 'Q3', 20)
insert into @sales values(2001, 'Q4', 90)
insert into @sales values(2001, 'Q4', 80)
insert into @sales values(2002, 'Q4', 35)

select * from @sales
PIVOT (
SUM(Amount)
for Quarter in (Q1, Q2, Q3, Q4)) as p

Yields...
Incorrect syntax near 'SUM'.

View 2 Replies View Related

Pivoting A Results Table MSSQL

Nov 12, 2007

I have a query in which I would like to pivot the resultsI presently have my results displaying something like this. OrderNumber    Product       OrderQuantity---------------        ---------------    ----------------------0608                Prod1          30608                Prod2          120608                Prod3          2 What I am after is for the results to display something like this.OrderNumber    Prod1   Prod2   Prod3 
---------------        ---------   ---------  ---------
0608                3           12       2 This is using SQL Server ver 8.0  

View 3 Replies View Related

T-SQL (SS2K8) :: GROUP BY CUBE Aggregation - Pivoting On 2 Totals

Aug 1, 2014

I'm trying using the GROUP BY CUBE aggregation. Currently I have this working as such:

SELECT
ISNULL(CONVERT(VARCHAR,Date), 'Grand Total') Date
,ISNULL([1 Attempt],0) [1 Attempt]
,ISNULL([2 Attempts],0) AS [2 Attempts]
,ISNULL([3 Attempts],0) AS [3 Attempts]
,ISNULL([4 Or More],0) AS [4 Or More]

[Code] .....

Basically this is used to work similar to a Pivot table in excel. My data will look as follows:

Date 1 Attempt2 Attempts3 Attempts4 Or MoreTotal
2012-09-04 239 68 2 8 317

The problem I'm having is the Total column. Although this is summing the line values correctly, the total should be based on the sum not count of attempts i.e. 1 x 239, 2 x 68, 3 x 2, 4 x 8

If I change the FROM select clause to use SUM instead of COUNT

SELECT
CONVERT(DATE,[Date]) Date
,ISNULL(AttemptsFlag,'Total') as Attempt
,SUM(NoOfTimes) AS Totals
FROM
XXXXX
GROUP BY
CUBE([Date],AttemptsFlag)

It will return the correct Total amount but not the right numbers for the Attempt groupings...

View 1 Replies View Related

SSRS -- Data Driven Subscription And Pivoting For Dynamic Parameter Mapping

Feb 12, 2007

Hi,

For the Data Driven Subscription in SSRS we are using the following stored procedure

In Step 3 - Create a data-driven subscription



create procedure spRSGetReportSettings

(

@ReportID as integer

) as

begin

set nocount on

declare @t as table(y int not null primary key)

declare

@cols as nvarchar(max),

@y as int,

@sql as nvarchar(max)

set @cols=stuff(

(select N',' + quotename(y) as [text()]

from (select ParameterName as y from Reportsettings where reportid=1) as Y

order by y

For XML Path('')),1,1,N'');

set @sql=N'select * from

(select reportid,parametername, parametervalue from ReportSettings where reportid= ' + Cast(@ReportID as varchar(5)) +' ) as D

pivot(min(parametervalue) for parametername in(' + @cols +N')) as p'

exec sp_executesql @sql

end



Basically the idea is to maintain a single report parameter setting table for multiple reports.

Structure of the table is as given below

ReportID, ParameterName, ParameterValue.

Using Pivot we can generate the ParameterName/ParameterValue combinations for each report. This stored procedure is working fine in query editors(Management Studio)

But, in SSRS it is giving any results.

In Step 4 - Create a data-driven subscription,

Get the value from the database drop down, I am not getting any database columns.

Please help.

Kumar

View 3 Replies View Related

Recordset With SQL And VB

Jul 10, 2007

Hi,
I am trying to cycle through a table and trigger an event based on some critera. I am not sure how to do it. I am a classic VBA guy, so I might be way off:
   Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
myConnection = New SqlConnection("MY SQL DATA SOURCE")
myConnection.Open()

myCommand = New SqlCommand("SELECT * FROM history", myConnection)
Dim dr = myCommand.ExecuteReader()
Dim i As Integer = 1

While dr.read()
i = i + 1
' HOW DO I CYCLE THROUGH THE ROWS AND ASK IF A FIELD EQUALS A VALUE
' field name = "Tail"

If dr(i) = ? Then
MsgBox("ok")
End If

End While
dr.Close()
myConnection.Close()
 

View 3 Replies View Related

VB.NET SQL Recordset

Jun 22, 2008

Hello, what is the best way to iterate both forward and back through my SQLDataAdapter/SQLDataReader in code?

View 1 Replies View Related

How About Recordset?

Jul 24, 2001

In VB to move a recordset, we used .MoveNext. How about in SQL?
How can I compare two fields in SQL?

View 1 Replies View Related

Recordset

Mar 12, 2006

hi
I have 3 tables:Article,Source and File.
Each article can have multiple filenames.
The fields of table Article are:ArticleID,SourceID,ArticleDate,ArticleCategory
The fields of table Source are:SourceID,SourceName
the fields of Table File:ID,ArticleID,Filename
Select*from Article inner join Source on Article.SourceID=source.SourceID order by ArticleDate
I obtain a number of recordsets from the above query.
Then for each recordset(Rs1),Let's say for the first recordset
Rs1.MoveFirst
I want to apply this query:
Rs2.Open"Select SourceName,ArticleDate,File.Filename from [RS1] inner Join File on Article.ArticleID=File.ArticleID
I want from the above query to have the Filenames corresponding to each Article because in my VB
form I have 2 command buttons:one gives me the article's definition(Date,Source)
and the other gives me the Filename of the current recordset(Article)
The above SQL syntax is it correct?

View 2 Replies View Related

How To Get The Second Row Of A Recordset?

Aug 18, 2006

Here's my SQL Statement (I'm using MS SQL 2000):

SELECT TOP 2 MenuComments, MenuDate, MenuID, MenuIsActive, MenuName
FROM Menu
ORDER BY MenuDate DESC

This orders the data correctly, but the problem is, I need ONLY the SECOND row, not the top row. Also, because I am sorting for menus entered into the system, I cannot use a variable based on real dates (in other words, I can't use the server clock to help filter the results).

Any and all help would be GREATLY appreciated -- I've been banging my head against this one all day!

Mike

View 3 Replies View Related

One Recordset Instead Of Two

Jul 11, 2007

Hi,


I am using classic ASP.
Records are grouped together by a GroupUnique number. Some groups are small with about 10 records, othere are larger at about 160.

For each record, I have about 50 columns of data that I need to display on a webpage. Because the 50 columns don't easily fit on the one page, I create two tables, each displaying 26 columns, the first columnn being an ID column. Due to the size of groups, sometimes the tables are very large - and when they get too big it overloads the server.

I think the main problem is the two tables. I use two recordsets (one of them is shown below - although instead of a SELECT * I do in fact name the columns needed for each table). I have to use two because the Recordsets don't like me using the ID column again - once it is used it is gone.

Is there a better way to store all of this information so that I can just use the one recordset? Possibly in an array? Is there a more efficient way of getting the data?








<%
Dim Recordset4__MMColParam1
Recordset4__MMColParam1 = "1"
If (Scramble.Fields.Item("GU").Value <> "") Then
Recordset4__MMColParam1 = Scramble.Fields.Item("GU").Value
End If
%>

<%
Dim Recordset4
Dim Recordset4_numRows

Set Recordset4 = Server.CreateObject("ADODB.Recordset")
Recordset4.ActiveConnection = conn
Recordset4.Source = "SELECT * FROM Table1 WHERE GroupUnique = " + Replace(Recordset4__MMColParam1, "'", "''") + ""
Recordset4.CursorType = 0
Recordset4.CursorLocation = 2
Recordset4.LockType = 1
Recordset4.Open()

Recordset4_numRows = 0
%>


<%
Dim Repeat4__numRows
Dim Repeat4__index

Repeat4__numRows = -1

Repeat4__index = 0
Recordset4_numRows = Recordset4_numRows + Repeat4__numRows
%>

View 4 Replies View Related

Recordset And Asp

Sep 2, 2005

Hi guys,

my first post. So please don't kill me!

I am having some problems. I'm pretty new to sql and really dont know how to achieve more than the basic selects etc.,

My problem is that I have a recordset on one page http://www.photoghetto.com/photo-images/animals.asp that returns the results of all the images in one category. In this case it's animals and wildlife.

The user can click on any image and go to a page that shows a larger detail version of the image. http://www.photoghetto.com/photo-images/animals-photo-detail.asp

What I do is post the ProductID number to this page so that the selected thumb is shown. So for exmaple for the image of the wild cat it is http://www.photoghetto.com/photo-images/animals-photo-detail.asp?ProductID=6

My problem is that on the animals-photo-detail.asp the user has to be able to "scroll" through all the images from the category.

I.e should be able to hit the previous image button and see the stallion image, or the next button to see the butterfly etc., and thus scroll through all the images on this age if he/ she wishes to.

I understand the principles of having a results page and then being able to click on one of the results and getting a detail page. Such as I have it here. With the http://www.photoghetto.com/photo-images/animals.asp as a results page listing all the results of the category, and then when the user clicks on one of the results, goes to a detail page, for example, http://www.photoghetto.com/photo-images/animals-photo-detail.asp?ProductID=6.

My problem is that what I need is the recordset from the listing page to function on the detail page so that the user can scroll through the results in the same order that they were on the results page.

I have searched now for a couple of days online and every tutorial I find shows the same structure. Results Page > Detail Page.

The sql i am using on the detail page is simply,

<%
Dim photos_rs__MMColParam
photos_rs__MMColParam = "1"
If (Request.QueryString("ProductID") <> "") Then
photos_rs__MMColParam = Request.QueryString("ProductID")
End If
%>

<%
Dim photos_rs
Dim photos_rs_numRows

Set photos_rs = Server.CreateObject("ADODB.Recordset")
photos_rs.ActiveConnection = MM_photo_STRING
photos_rs.Source = "SELECT * FROM PHOTOCOLLECTIONS WHERE ProductID = " + Replace(photos_rs__MMColParam, "'", "''") + ""
photos_rs.CursorType = 0
photos_rs.CursorLocation = 2
photos_rs.LockType = 3
photos_rs.Open()
photos_rs_numRows = 0
%>

So I understand why it will only display the one result since thats the detail page.

Is it possible to be able to scroll through the results using the previous and next buttons as I have setup in the display on the http://www.photoghetto.com/photo-images/animals-photo-detail.asp page. For example, http://www.photoghetto.com/photo-images/animals-photo-detail.asp=ProductID=6.

Since the resutls are gathered from across the database its not possible to have a href tage that does a <<< http://www.photoghetto.com/photo-images/animals-photo-detail.asp=ProductID=(6 -1) or a >>> http://www.photoghetto.com/photo-images/animals-photo-detail.asp=ProductID=(6+1).

I guess it has to be something with a recordset index but does anyone know how to do it? And does anyone have the ability to help me do it?

My boss is kicking my butt now to get this thing online at some point today, and I'm turning to you guys for help if possible.

I'm sorry if this is a stupid question. I've really ran out of ideas.

-SOM

View 9 Replies View Related

Recordset

Mar 27, 2007

is there any thing like a recordset concept in sql server,
where i could loop through and update each rows

Thanks,
MG

View 5 Replies View Related

Recordset

Nov 23, 2005

This asp code displayes records in a combo box:<%openDB()call updateDB("usp_retrieveOptions",rs)if not rs.eof then%><tr><td width="66">Options</td><td width="137"><select name="select1" class="TextField1"><%i = 0do while not rs.eofif rs(0) <> Arr(i) thenresponse.write "<option value=" & rs(0) & ">" & rs(1)i = i + 1end ifrs.movenextloop%></select></td></tr><tr><td colspan="2" width="206"><center><table width="71" border="0" cellspacing="3" cellpadding="0"height="33"><tr><td width="9" height="30"><input type="submit" name="Assign" value="Assign"></td></tr></table></center></td></tr><%end ifcloseRS()closeDB()%>The call updateDB("usp_retrieveOptions",rs) invokessub updateDB(SQL,rs)set rs = objConn.Execute(SQL)end suband my usp_retrieveOptions stored procedure:create procedure usp_retrieveOptionsAS SET NOCOUNT ONSELECT OptionID, Description FROM OptionsReturnGOnow in my asp code when I try response.write rs.RecordCount I am getting-1 all the time. How do I solve the problem. Your help is kindlyappreciated.Eugene Anthony*** Sent via Developersdex http://www.developersdex.com ***

View 4 Replies View Related

How To Use A Value From One Recordset In Another..?

Jul 20, 2005

Im doing a select that should retrieve a name from one table and display thenumber of correct bets done in the betDB (using the gameDB that has info onhow a game ended)I want the "MyVAR" value to be used in the inner select statement withouttoo much hassle. As you can see im trying to get the "MyVAR" to insert inthe bottom line of the code.Whats the quick fix to this one..?Thanks in advance :-)---------- code begin ----------select memberDB.memberID as MyVAR, (select count(GamesDB.GameID)from GamesDBinner join GameBetDBon GameBetDB.betHome = GamesDB.homeGoal and GameBetDB.betAway =GamesDB.awaygoalinner join memberDBon memberDB.memberID = GameBetDB.memberIDwhere GamesDB.gameID=GameBetDB.gameIDand GameBetDB.memberID= MyVAR ) as wins from memberDB---------- code end ----------

View 1 Replies View Related

How Do I Declare A Recordset ?

Aug 25, 2006

Hi allHow do i declare a recordset and fetch records from an sql server?TIAGuy

View 3 Replies View Related

Query With Recordset

Jun 22, 2004

Hello,

I am connecting to the database as following:
set con = server.createobject("adodb.connection")
con.open "connectionstring"
set rs = con.execute("select * from tablename")

I am able to display the records but if I want to give adopenstatic to the above connection, how can I do so?

Thanks in advance,
Uday.

View 1 Replies View Related

Pb To Edit A Recordset With VB In A DTS

Nov 24, 2001

Hello,

I have some problems to edit a recordset in an ActiveX DTS using Vbscript.
Here is an example of the script :

dim varsql, varset, varconn
set varconn = CreateObject("ADODB.Connection")
set varset = CreateObject("ADODB.Recordset")
varconn.Open = "Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=Enregistrement3;user id = 'sa';password=''"

varsql = "SELECT * "
varsql = varsql & "FROM mytable "
varset.Open varsql, varconn, 3,3

msgbox "How much : " & varset.recordcount

if varset.recordcount >0 then
do while varset.eof
varset.edit
.........................
varset.update
varset.movenext
loop
end if
varset.close
varconn.close

Does someone see what is wrong ?
I allways get -1 for the varset.recordcount ! (I checked there are some records into the table).
I don't think it is a problem of user's right as it works with the same user configuration using a SQL action requery.
If I modify the open statement like this :
varset.Open varsql, varconn, 1
varset.recordcount contains the good number of records but the recordset is read noly and can't be modified...

Any Help will be very wellcome !
TIA

View 1 Replies View Related

Using DTS For Returning In The Recordset

Sep 29, 2000

Is possible use DTS for return Data in recordset in the VB ?

I am asking this , why I have access the database INFORMIX, and several things do not work with Stored Procedure in the Informix

thank you in advance

View 1 Replies View Related

Looping Through A Recordset In A SP

Aug 30, 1999

What I have to do is loop through a table with about 900 records, do computations on each record and update a database, can someone help me out.

here is the code that I am using right now on another site with coldfusion but i want to convert it all to a stored proc for speed reasons.

<!--- Query the Stores Table --->
<cfquery name="Zip2" datasource="#application.data#" username="#application.username#" password="#application.password#">
exec Stores_GetStoreZipInfo
</cfquery>

<!--- Loop through the STORE table --->
<cfloop query="zip2">
<cfset Lat1 = #zip1.lat#>
<cfset Lg1 = #zip1.long#>
<cfset Lat2 = #zip2.lat#>
<cfset Lg2 = #zip2.long#>

<!--- Do the actual distance calculation between the user's zipcode each store's zipcode --->

<cfset DistLat = 69.1 * (Lat2-Lat1)>
<cfset DistLong = 69.1 * (Lg2-Lg1) * #cos(Lat1 / 57.3)#>
<cfset Dist = ((#abs(DistLat)# * 2) + (#abs(DistLong)# * 2)) * 0.5>

<!--- Update the DISTANCE field on STORE table --->
<cfquery name="UpdateZips" datasource="#application.data#" username="#application.username#" password="#application.password#">
exec Stores_UpdateZipSeachInfo '#Dist#', '#zip2.zipcode#'
</cfquery>
</cfloop>

View 1 Replies View Related

Getting Partial Recordset.

Apr 19, 1999

I'm an SQL novice, but I know this must be a common problem.

I'm trying to select a recordset (using ASP), but I know I only want part of the recordset, and am not sure how to limit it ahead of time.

For example, the query will return about 500 rows, but I know I only want to use a small section of these records.
I want to give the user the ability to navigate through small sections of these 500 rows without having to get all rows all the time.
I know ahead of time which rows to get, but have no idea how to limit the recordset before I get it (there is no fields in the database to help).

This is what I'm doing now. "select * from xyz where id=xxx order by date desc;" I know I only want the first 10, or 10-20, or 400-410.
The way I'm doing it now, I'm getting the whole recordset each time, doing a "rs.move x" where x is where I want to start.
This is really a waste of network traffic and memory since my SQL server is on a different machine as the web server running ASP.

How do I do this?

Please email me if you could at pmt@vantagenet.com

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved