473,573 Members | 3,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

transform recordset

Hi,

I have table where i have the following fields in datasheetview:

id | date | image | question1 | question2 | question..N

I would like to have it in this way:

id | date | image | questionnr | answer
1 01-01-2004 test.tif 1 1000 (this is the value of
field question1)

As you can see the first 3 fields remains the same, but the records of those
3 fields should be inserted for each record of the question fields. I can do
this with a union query for each questionfield, but.....

How can i do this automatically, because there are more than 500 columns.
Jul 20 '05 #1
1 1143

"EzekiŽl" <ezekiŽl@lycos. com> wrote in message
news:41******** *************** @news.wanadoo.n l...
Hi,

I have table where i have the following fields in datasheetview:

id | date | image | question1 | question2 | question..N

I would like to have it in this way:

id | date | image | questionnr | answer
1 01-01-2004 test.tif 1 1000 (this is the value of
field question1)

As you can see the first 3 fields remains the same, but the records of
those
3 fields should be inserted for each record of the question fields. I can
do
this with a union query for each questionfield, but.....

How can i do this automatically, because there are more than 500 columns.


I believe "datasheet view" is an Access term - are you using Access or
MSSQL? Or Access with an MSSQL backend? Assuming you have MSSQL, you could
write something to do this, but I would suggest that you take the time to
fix your data model instead, as it will make everything easier for you.
Also, since MSSQL allows only 1024 columns per table, your current data
model means you are quite limited in the number of questions you can store.

Something like this might be a rough starting point:

create table Questions (
QuestionID int not null,
Question varchar(1000) not null,
Answer varchar(1000) not null,
constraint PK_Questions primary key (QuestionID)
)

create table Datasheet (
DatasheetID int not null,
DatasheetDate datetime not null,
ImageFileName varchar(1000) not null,
constraint PK_Datasheet primary key (DatasheetID)
)

create table DatasheetQuesti ons (
DatasheetID int not null,
QuestionID int not null,
constraint PK_DatasheetQue stions primary ky (DatasheetID, QuestionID)
)

Now your query is a simple join:

select
d.DatasheetID,
d.DatasheetDate ,
d.ImageFileName ,
dq.QuestionID,
q.Answer
from
Datasheet d
join DatasheetQuesti ons dq
on d.DatasheetID = dq.DatasheetId

join Questions q
on dq.QuestionID = q.QuestionID
order by
DatasheetID, QuestionID

Simon
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4665
by: Alex Vinokur | last post by:
Functor-parameters in the for_each() and transform() algorithms are passed by value. Might it make sense to have also algorithms for_each2() and transform2() which pass Functor-parameters by non-const reference? Here is some program which demonstrates probable necessity in such forms of for_each() and transform().
0
3010
by: Xiaolei Li | last post by:
first off, i'm a total newbie at this stuff so excuse any wrong usage of terminology or whatever else. i have a XSL to transform a Document such that all "text" nodes will have a "SPAN" inserted around it. the XSL is given below: <xsl:transform version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xhtml" ...
2
1024
by: John Lehmann | last post by:
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty well for simple transforms. But as soon as I add Xsl variables or For each loops to the XSL string in the db, it fails to transform the XML. I can...
0
1435
by: glen | last post by:
I used the below code to transform xml to a spreadsheet using a .xsl file. It works great; problem is I want to transform several recordset to xml to multiple worksheets in the workbook. Should I use something other than the "transformNodeToObject"? I can't see how to direct the xml to different worksheets. I appreciate any help. <%@...
4
4812
by: schneider | last post by:
Anyone know if there is a way to dynamicly create a Xslt template/s and use them as an xml transform with-out use files for the Xslt? All the methods I see use files. I want to create a Xslt transform via code? Any examples would be great.
3
2376
by: Rouven Hertenstein | last post by:
Hi, I'm trying to test the vb.net-exercise "How to use a DataSet with the Office XP Chart Component and ASP.NET" on http://support.microsoft.com/kb/303016/en-us Visual Studio rails against the expression: "xslTran.Transform(xmlDoc_ds, Nothing, context.Response.Output)" and comments: "Public Sub Transform(input As...
32
2660
by: Indrid Colt | last post by:
Thank's for your help ! Indrid
1
1848
by: Mike Hofer | last post by:
I've got two statements in my code that are both generating weird, weird, weird messages: The first one was, Dim document As System.Xml.XmlDocument Dim navigator As System.Xml.XPath.XPathNavigator Dim transform As System.Xml.Xsl.XslTransform .. ..
4
8514
by: Dean Card | last post by:
Okay, so here is the situation. I have need to do some on-the-fly image creation. I have everything working great except for the last part of it, applying a perspective type transform to the image. The transform will take a rectangular 2D image and transform it to a 3D representation in 2D. Please see the link to see what I am trying to...
6
4954
by: Vijai Kalyan | last post by:
Hello, I am trying to use std::transform to take in a collection of strings, transform them and insert the result into an output container. So, I wrote something like this: std::wstring doSomething (std::wstring const& str) { // do something to copy of str and return new value }
0
8016
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7773
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8061
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6411
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectóplanning, coding, testing, and deploymentówithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5584
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5289
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2197
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1297
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.