I’ve only been able to see this work with a stored procedure and I can’t figure out the syntax. I basically have some external system calling a SQL query and I want to verify the table exists first using code similar to this:
if (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'OrderUpdates'))
BEGIN
--return 1 or 0 if it exists or doesn't exist
END
I can’t get the return statement to work properly.
1 Answer