|
Hello, Can you please explain to me what the script below does? If possible, line by line. Thank you in advance. ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
(comments are locked)
|
|
I'm working under the presumption that "Databasename" for the For each user table (that's the "sys.sysobject a" bit) in the current database that has any rows ("sys.sysobjects b" and "and b.rowcnt > 0"), it is generating an It's using DISTINCT because the join between a and b can result in multiple rows for each table (a table can have 1 or more rows in sys.indexes), but the script only wants one "insert into select" statement per table. Because this snippet is just generating the statements and not executing them, it's safe to run as you have presented it. Then you can take a look at the output to see what it would do.
(comments are locked)
|

