Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | abenitez77Yak Posting Veteran
 
 
                                        53 Posts | 
                                            
                                            |  Posted - 2015-03-01 : 22:23:46 
 |  
                                            | I have a list in Excel that has a list of about 30 tables with all column names and types. How can I programatically create the tables using this list with the datatypes listed in the excel file ? I thought of importing the list into a table and using a cursor to loop thru the list and build the Create table command, but I've never used cursors before.Column_Heading is just a label...use column_name as the column name to be used. Also, the Char data_type could be Varchar.This is a sample of the list:TABLE_NAME	COLUMN_NAME	ORDINAL_POSITION	COLUMN_HEADING	DATA_TYPE	LENGTH	NUMERIC_SCALEAAHHSTHP	AAHCMPN	1	Company number CHAR	3	AAHHSTHP	AAHDIVN	2	Division number CHAR	3	AAHHSTHP	AAHDPTN	3	Department number CHAR	3	AAHHSTHP	AAHVNDN	4	Vendor number CHAR	10	AAHHSTHP	AAHPINB	5	Journal inv/ref numb	CHAR	10	AAHHSTHP	AAHLNAH	6	History line number NUMERIC	5	0AAHHSTHP	AAHIAMG	7	Invoice amount-gross	DECIMAL	15	2AAHHSTHP	AAHIAMD	8	Invoice discount amo	DECIMAL	15	2AAHHSTHP	AAHIAMZ	9	Invoice amount-no ds	DECIMAL	15	2AAIHSTDP	AAICMPN	1	Company number CHAR	3	AAIHSTDP	AAIDIVN	2	Division number CHAR	3	AAIHSTDP	AAIDPTN	3	Department number CHAR	3	AAIHSTDP	AAIVNDN	4	Vendor number CHAR	10	AAIHSTDP	AAIPINB	5	Journal inv/ref numb	CHAR	10	AAIHSTDP	AAILNAH	6	History line number NUMERIC	5	0AAIHSTDP	AAILNAP	7	Payable line number NUMERIC	5	0 |  |  
                                    | gbrittonMaster Smack Fu Yak Hacker
 
 
                                    2780 Posts | 
                                        
                                          |  Posted - 2015-03-02 : 04:05:32 
 |  
                                          | either:1. Using VBA in Excel, build up the create table command then send it to the server2. using Dynamic SQL, build the create table command as a nvarchar variable then execute the command with sp_excutesql |  
                                          |  |  |  
                                |  |  |  |