How I List all possible variations????

  • I'm having a db programming drama. We have a series of questionnaires;

    each questionnaire is comprised of a series of forms that a user must

    fill out. A document is produced at the end of the questionnaire. Some

    of the fields are required and some are not, depending on how the

    fields are filled out can make the document look very different.

    My aim is to produce something that lists all the possibilities that

    the question can be filled out in. The list of the form fields are in

    a SQL Server 200 database table "tblDocPageFields", the structure of

    the table is similar to this:

    tblDocPageFields

    - ID

    - Page ID

    - Field Name

    - Field Order

    Another table specifies whether the field is required or not which

    contains the fieldID and a validation Message to be displayed if the

    field is not filled in.

    tblDocPageFieldsReq

    - ID

    - FieldID

    - ValidationText

    For example if I have a document with 2 fields and the first one of

    them are required the possibilities are:

    Field1 Field2

    Filled Nothing

    Filled Filled

    NothingFilled

    I need to be able to list this somehow, as some of the surveys have a

    huge amount of questions that need to be checked for all

    possibilities. Does any one have any idea How I can accomplish this

    through a stored procedure or ASP logic or something… Please help!!!

    ryan@lawcentral.com.au

  • Your problem is similar if not the same as one discussed a few weeks ago with the subject line something like ....dynamic cross join query ... will see if I can get the correct heading....

  • Hi rmalone,

    this is an interesting question!

    You need to calculate all permutations of Page ID.

    The number of permutations of n elements is n! This will quickly grow to a very large number.

    If you have 5 pages to fill the number of all possible outcomes is 120, if you have 10 page the number is 3,628,800.

    I have no example code, but I'm pretty sure you'll find this on asp or vb site like http://www15seconds.com or http://www.planetsourcecode.com.

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply