question

ammu avatar image
ammu asked

how to write a query for this requirement?

I have table(Sheet_name) like Sheetname Tblname Ecom Ecom Drug Drug like that. im having tables in my database with these Tblname like Ecom table Im having and Drug table im having. Now i need to rename my tables with Tblname_datepart, the tbl name which is existed in the sheet_name table.how to write a query? can any one heplp me. Thanks in advance.
existing-table
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

SQLGoooRooo avatar image
SQLGoooRooo answered
Renaming a table is fairly simple and there's a stored procedure to do so. http://msdn.microsoft.com/en-us/library/ms188351.aspx
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JohnM avatar image
JohnM answered
As mentioned by @SQLGoooRooo, renaming a table is indeed fairly simple however keep in mind that any code that is referencing that table (view w/o schemabinding, stored procedures, functions, entity framework, etc) will need to be updated to reflect the new name otherwise things will potentially cease to function correctly. If you are unsure on what is referencing that table, you can right click the table name and select "View Dependencies" to see what might be referencing it. That however will not tell you of any ORM's that are using it. Hope this helps!
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Agree with JohnM. Whenever I do DDL queries like this I always ensure to do it in a test environment such as Development or Stage where you're completely separate from any production system. You will likewise want to test the full functionality of the dev/stage frontend to make sure you didn't break the system. Once you are certain, only then it's wise to move to production.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.