create table dynamic | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

create table dynamic

i create a table dynamic so that i use varaiable, when i execute it, it doesnt create it. eg/ as below DECLARE @SQLNVARCHAR(2000) SET @SQL = N’CREATE TABLE #TEST_CREATE1 ‘
SET @SQL = @SQL + ‘ ( IDINT, NAME VARCHAR(100))’ EXEC (@SQL) but this doesnt create table?. i am not sure how many columns in a table, that will be added at runtime. any syntax prob? or create table statement will not work in this way when select, insert all working ?.

use GLOBAL TEMP TABLE
DECLARE @SQL NVARCHAR(2000) SET @SQL = N’CREATE TABLE ##TEST_CREATE1 ‘
SET @SQL = @SQL + ‘ ( ID INT, NAME VARCHAR(100))’ EXEC (@SQL)
KH
You know this one?http://www.sommarskog.se/dynamic_sql.html
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt?http://www.insidesql.de/blogs
Ich unterstuetze PASS Deutschland e.V. http://www.sqlpass.de)
]]>