Looping Sql Server

  • Hi,

    I need urgent that which i tried more times.I need a solution for looping SQL

    Query. I am assigning data to the field which is changing

    dynamically. Here i have given query

    My field name is Daily1,Daily2,Daily3.

    Now I am going to assign different value for Daily1,Daily2,Daily3.

    For Example

    Daily1- Sunday

    Daily2-Monday

    Daily3-Tuesday

    I need to change the number like Daily(i).For i=1,2,3;

    How can make loop?

    Pls give the solution. __

  • saranram_forum (4/3/2009)


    Hi,

    I need urgent that which i tried more times.I need a solution for looping SQL

    Query. I am assigning data to the field which is changing

    dynamically. Here i have given query

    My field name is Daily1,Daily2,Daily3.

    Now I am going to assign different value for Daily1,Daily2,Daily3.

    For Example

    Daily1- Sunday

    Daily2-Monday

    Daily3-Tuesday

    I need to change the number like Daily(i).For i=1,2,3;

    How can make loop?

    Pls give the solution. __

    Two things. First you may not need a loop. Unfortunately it is difficult to tell based on the vague requirements provided. Which leads to two, what are the requirements of what you are attempting to accomplish. Please provide DDL for the table(s), sample data, expected results, and what you have done so far (code wise) to accomplish your task.

    Please read the first article I reference below in my signature block regarding asking for assistance. It will give you detailed explanation on how best to post your question to get maximum assistance.

  • Eventhough it si not at all a good idea but you can use cursor if no other option left.

    Please specify the exact requirement as Lynn said. so that we can have a better approach

    MJ:cool:

  • Hi

    You want to do this in SQL statement or with the help of T-SQL?

  • Hi,

    I need T-SQL.Pls give the solution.

  • 3.14159265358979323

    There is the solution for pi (at least as far as I have it memorized).

    Now as per the post above, instead of asking for "the solution" can you please provide specifics as to what the requirements are? I am not trying to be insulting, but asking for a solution without clarifying the problem will yield a solution to a different problem (at the interpretation of the reader). Not to mention it will waste time.

    Again, please provide table structure, how you would like the solution (I would assume a stored procedure which takes parameters, but I don't want to waste anyone's time assuming) what the input should be, and what the expected output is.

    Thanks!

  • saranram_forum (4/7/2009)


    Hi,

    I need T-SQL.Pls give the solution.

    Solution to what? You haven't provided us with enough information do help you yet. Have you read the article I recommended?

Viewing 7 posts - 1 through 6 (of 6 total)

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