I am in the foothills of writing a procedure that given an existing table name recreates it's structure and saves the data therein into a temporary table.The built in script generator in SSMS is great in that if I ask it to script a table (for example to do an INSERT INTO), typically it creates the following kind of script:INSERT INTO [SQNSA].[dbo].[Address] ([Nadnr] ,[Name] ,[CountryCode] ,[IdPlace] ,[PostCode] ,[NadLines] ,[IdBusinessType] ,[Phone] ,[Fax] ,[WebSite] ,[IdHQ]) VALUES (<Nadnr, varchar(6),> ,<Name, nvarchar(65),> ,<CountryCode, varchar(2),> ,<IdPlace, int,> ,<PostCode, varchar(10),> ,<NadLines, nvarchar(120),> ,<IdBusinessType, int,> ,<Phone, varchar(30),> ,<Fax, varchar(30),> ,<WebSite, varchar(50),> ,<IdHQ, int,>)GO
How can I replicate this behaviour in my own code?I've written something along the lines of:SELECT Column_Name, Data_Type, CASE WHEN CHARACTER_MAXIMUM_LENGTH IS Null THEN '' ELSE '(' + CONVERT(VARCHAR(20),character_Maximum_Length) + ')' END AS Length FROM [INFORMATION_SCHEMA].COLUMNS WHERE [TABLE_NAME] = 'Address' ORDER BY [ORDINAL_POSITION] ASCbut still a long way from getting usable resultsSQL2008 and Visual Studio 2008 (VB Preferred)