Hello I have a dynamic query like
SET @template = 'SELECT x AS X,... INTO temporalTable FROM' + @table_name
Then I execute it
EXEC (@template)
- How do I validate if
temporalTable
already exists, if so, drop it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use information schema or
sp_helpfunction.I would prefer information schema since it’s SQL ANSI and you can port the code to other databases:
sys.tablesis a SQLServer specific option similar to inforamtion schema that you can also explore.