User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 426,429 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,361 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums

add a new table to the database or add a new column to an existing table.

Join Date: Aug 2007
Posts: 98
Reputation: GLT is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
GLT GLT is offline Offline
Junior Poster in Training

Re: add a new table to the database or add a new column to an existing table.

  #8  
Apr 9th, 2008
Ive been having aply with my code and trying to find information on this. It looks like I have to use dynamic SQL which I have never used before. Here is the SQL code I have now:-

CREATE PROCEDURE sp_createtable
(
@txttablename as varchar(50),
@column1 as varchar(50),
@select1 as varchar (50),
@column2 as varchar(50),
@select2 as varchar(50),
@column3 as varchar(50),
@select3 as varchar(50)
)
AS
DECLARE @SQL varchar(2000)
SELECT @SQL = 'create Table' + @txttablename+')'
SELECT @SQL = @SQL + 'ID identity NOT NULL PRIMARY KEY, @txtcolumn1 @txtselect1, @txtcolumn2 @txtselect2, @txtcolumn3 @txtselect3)'
Exec(@SQL)

is this right? my SQL Server is down at the minute so I cant test it. I am trying to insert the tablename, column names and datatype from as asp form.

ideas would be great!
Thanks GLT
Reply With Quote  
All times are GMT -4. The time now is 2:29 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC