Welcome Guest! Log in
×

Notice

The forum is in read only mode.
Due to some maintenance operations, stambia.org will be switched to read-only mode during the 13th November. It will be possible to read and download, but impossible to post on the forums or create new accounts. For any question please contact the support team.

Topic-icon Solved How to provide dynamic SQL table name as metadata in sql operation

More
10 Oct 2017 14:43 #1 by nikita.barve
nikita.barve created the topic: How to provide dynamic SQL table name as metadata in sql operation
Hello ,

we generate daily backup of d_stockiest table with timestamp appended.
i wrote dynamic sql loop query for deleting all backup tables one by one except recent 5 backup tables.

but it gives bellow error :"Cannot drop the table 'd_stockist_hq_mapping_bkp_20171010173223', because it does not exist or you do not have permission".


because name of table to be deleted is dynamic so i cant drag that metadata on sql operation.

if i run these query on sql server it works n it gives below result



please suggest solution
Attachments:
More
10 Oct 2017 17:19 #2 by Thomas BLETON
Thomas BLETON replied the topic: How to provide dynamic SQL table name as metadata in sql operation
Hi,
The error message mentions that the table might not exist or the user does not have permisssion to drop the table.
Can you check this last point ?

You can try adding the catalog.schema prefix to the table name too (sql server's query tool has a "current" database set, the stambia process might not have such thing, depending on how your metadata is configured).
For example : Drop table db01.schema01.d_stockist_...
More
14 Nov 2017 07:05 #3 by nikita.barve
nikita.barve replied the topic: How to provide dynamic SQL table name as metadata in sql operation
Hi,

Thanks for your solution .
its working properly.


Thanks & Regards,
Nikita Barve