Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Question Unanswered: Need help with large SP (Dynamic SQL)

    Hello all, I am new here. I am a SQL newbie, but I have a huge task assigned to me. I basically have to count rows in a bunch of tables where certain 'marked' columns don't have any NULLs. Consider the following example:

    http://db.tt/yJ1t0j6v

    Please note that Table A contains many more columns, but only the 4 shown are to be considered. For the assignment, the total table count is 40, total column count is around 1400 and the average rows count across the 40 tables is ~5000.

    To flesh out my dynamic SQL for the commented cell in the above example, I wrote the following code using a couple of cursors: http://db.tt/EJAPKLWW CONFIGURATIONITEMATTRIBUTES = top portion of the above example.

    My output contains an additional 'OR' as shown here; I can't seem to get rid of it: http://db.tt/v4h3i5DL I understand why it is there, but as I am new to writing SPs (this is my first attempt), I don't know how to get rid of it.

    Once the SQL statements are properly formed, I will also need to replace all the 'print' commands with a proper INSERT statement to get the 'Statistics' table shown in the bottom portion of the example.

    I apologize for the dropbox links; I am just trying to be careful with company information. Finally, I have crossposted this on another site; if this is against the rule, please let me know.

    Thanks much in advance! Please do ask if anything is unclear.
    Last edited by zxx; 07-05-12 at 15:31.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •