How can i bring this output

  • This is my table structure

    tag table

    Tag TableName FieldName

    abc wc s_name

    lbl wc s_des

    lb2 wc s_prod

    in above fieldname(s_name,s_des,s_prod) column represent field in wc table.

    Wc table

    id s_name s_des s_prod s_txt s_new

    001 xx des1 prd1 txt1 txt2

    002 yy des2 null nul aa

    wc table contains around 45 field, i just furnishe only few fields.

    My output should be

    if i send wc.id as 001 i need result like below

    Tag value

    abc xx

    lb1 des1

    lb2 prd1

    if i send wc.id as 002 i need result like below

    Tag value

    abc yy

    lb1 des2

    lb2 null

    i need to reterive the result against field display in tag table (i.e fieldname). the level may increase.

    In case tag table contains s_new value in fieldname column. i need to show that result also.

    (eg)

    wc.id=002

    Tag value

    abc yy

    lb1 des2

    lb2 null

    xx aa

    How can i bring this result. is this possible without using cursor. i was struggling past two days. i cant able to bring result for above.

    can any one please guide me through sample code.

  • Suresh, your issue s exactly similar to the one posted under this:

    http://www.sqlservercentral.com/Forums/Topic920770-392-1.aspx

    I have given a code that will work for the requirement! Please go through that , Suresh!

  • urzsuresh (5/13/2010)


    This is my table structure

    tag table

    Tag TableName FieldName

    abc wc s_name

    lbl wc s_des

    lb2 wc s_prod

    No, this isn't a table structure. All it is is some columns and some data. We can't tell if there are any int columns, etc. (though we could make some guess). If it were the table structure, we'd see a CREATE TABLE statement.

    You know, the people that help out here are all un-paid volunteers. Providing the DDL scripts (CREATE TABLE, CREATE INDEX, etc.) for the tables affected, and INSERT statements to put some test data into those tables that shows your problem will go a long way in getting people to look at your issue and help you out. Please include code for what you have already tried. Don't forget to include what your expected results should be, based on the sample data provided. As a bonus to you, you will get tested code back. For more details on how to get all of this into your post, please look at the first link in my signature. So, help us help you... show us all of this where we can easily copy it and start working with it.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

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

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