![]() ![]() Other changes add apostrophes at right places. Quotename is needed if you ever use special characters Instead of fetching twice, I rather set up no-exit loopįetch next from Tests into And then, if no row is fetched, exit the loop fast_forward enables some speed optimizationsĭeclare Tests cursor local fast_forward for local means the cursor name is private to this code All table names are prefixed with "TestData". The columns occur in a variety of tables within the database. The script is designed to rename columns whose names match a pattern, in this case with a "pct" prefix. Print sp_executeSQL next from Tests into Tests Set = N'exec sp_rename ' + + N',' + + '_Pct' + N', column' (This cannot be seen, except by noting whether the cursor can be placed on the subsequent line.). SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE 'pct%' AND TABLE_NAME LIKE 'TestData%' Simple Controller Loop Controller Once Only Controller. How do I pass the table name to the rename sp ? I'm not sure how to do that since the column names are in one of many tables. What is wrong and how do I fix it ? I tried wrapping the column name in brackets, and double quotes "" like some of the search results suggested. Msg 15248, Level 11, State 1, Procedure sp_rename, Line 213Įither the parameter is ambiguous or the claimed (COLUMN) is wrong. taste.When I try to run the following SQL snippet inside a cursor loop, set = N'exec sp_rename ' + + N',' + '_Pct' + N',''COLUMN'''
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |