About 961,000 results
Open links in new tab
  1. If table exists with dynamic query in SQL Server

    Aug 7, 2014 · Here is the checking whether table exists or not: IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N' + @TABLENAME + ') AND type in (N'U')) …

  2. I want to create/drop a dynamically-named temp table. Is there

    Jun 7, 2024 · If you want to use dynamic SQL, you'd need to use sp_executesql. If you're the only one with access to the code and control over the input in the TEMP_TABLE_NAME variable, …

  3. SQL Server DROP TABLE IF EXISTS Examples

    Dec 18, 2024 · Learn various ways to check if a SQL Server table exists before trying to drop the table to avoid the table does not exist error.

  4. Dynamically creating a SQL Server table with dynamic SQL

    Aug 8, 2022 · In this post, we are going to look at how we can use dynamic SQL to build a table programmatically which you can then use in your scripts. We are going to make use of the …

  5. Check for Existence Of Column And Update If Exists Using Dynamic SQL

    Feb 21, 2012 · SET @Source_Table = ‘Source_Table’ declare @SQL varchar(8000) set @SQL=’ ’ set @SQL='IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE …

  6. Dynamically creating a @table Table from a current table - SQLServerCentral

    Sep 27, 2016 · Create the table in main stored proc, then ALTER it using dynamic SQL. Since the temp table already exists, the dynamic SQL is basically a sub-proc of the main proc, and it can …

  7. sql server - Creating temporary table dynamically using condition ...

    Mar 10, 2019 · Use a global temporary table instead of a session-scoped one (##table instead of #table). This will allow you to create the table conditionally using dynamic SQL and then …

  8. Creating a table using Dynamic SQL in stored procedure get

    Apr 5, 2004 · This is how to do the above: CREATE OR REPLACE PROCEDURE SCP_TESTA as table_already_exists exception; pragma exception_init ( table_already_exists, -955 ); …

  9. Dynamically Creating a Table in SQL Server from Information …

    Jul 19, 2024 · This SQL script dynamically creates a table in SQL Server by utilizing INFORMATION_SCHEMA and system views. It constructs the table definition, including …

  10. sql server - SQL "if exists..." dynamic query - Stack Overflow

    You can use EXEC to execute sql statement, then call @@ROWCOUNT which Returns the number of rows affected by the last statement, to check row exists in sql select stetement.

Refresh