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 |
husseinj
Starting Member
8 Posts |
Posted - 2004-08-17 : 02:25:17
|
Hi everyoneI wish to create a table dynamically in sql server 2000 through vb 6.Is that possible?Thank you in advance |
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2004-08-17 : 06:50:03
|
YES, why not!- Sekar |
|
|
husseinj
Starting Member
8 Posts |
Posted - 2004-08-17 : 06:57:27
|
But how?Can you please help me find a way to do this please. |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-08-17 : 07:22:10
|
exec('CREATE TABLE MyTable ( MyColumn1 varchar(10), MyColumn2 int)')Kristen |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2004-08-17 : 07:23:20
|
Have you tried executing a CREATE TABLE statement in VB ??.. Are you getting any error ??...- Sekar |
|
|
husseinj
Starting Member
8 Posts |
Posted - 2004-08-17 : 07:54:15
|
quote: Originally posted by samsekar Have you tried executing a CREATE TABLE statement in VB ??.. Are you getting any error ??...- Sekar
Am really sorry i have never done thisCould you please help me do this with some examples.Thank you a lot |
|
|
amitkumarmadhukar
Starting Member
45 Posts |
Posted - 2004-08-19 : 16:25:05
|
Hi Dear,Very Easily , you Can Create Tables from VB there is two ways1. Let assume you have a ADO Connection and Command Set Like and follow this CodeCs.Commandtext="Create Table <TableName>(<FieldNames> <Variable_Type> (<Size>) <Identifier>,>(<FieldNames> <Variable_Type> (<Size>) <Identifier>,............,>(<FieldNames> <Variable_Type> (<Size>) <Identifier>)Cs.Executeand You Got your tableEx:Assume you have to Create Table named TEST , Which Fields are :Name,Address,Age,Sex then your code become to :Cs.CommandText="Create table TEST(Name Varchar(50),Address Varchar(100),Age int,Sex Varchar(6))Cs.Executeand you get your table in database.2. First You Develop a Stored Procedure for Creating Table look like:Create Procedure MyTable as CREATE TABLE MyTable ( MyColumn1 varchar(10), MyColumn2 int)and again supply commandtext,Cs.commandText="Exec MyTable <Parameter Names>Cs.Execute and you again u get your tableisn't Easy Dear Please Reply me if you don't get help from aboveamit kumar madhukar |
|
|
|
|
|
|
|