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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 ALTER AND INSERT in one batch

Author  Topic 

tomino79
Starting Member

13 Posts

Posted - 2005-12-02 : 03:22:47
hi all,
I thought that I am really good in T-SQL and because I Have certificates in SQL Server. But this problem is for me a big X-File.
I dont know why, or how, but it doesnt not work and I does not understand why... ?

drop table aa /* if the table exists */
create table aa ( i int )
insert into aa ( i ) values ( 0 )
insert into aa ( i ) values ( 1 )
alter table aa add j int
insert into aa ( i,j ) values ( 0,1 ) /* here !! error that "j" doesnt exists */

Can anybody help me ?

T.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-02 : 03:28:17
You need to use the command GO

drop table aa /* if the table exists */
create table aa ( i int )
insert into aa ( i ) values ( 0 )
insert into aa ( i ) values ( 1 )
GO
alter table aa add j int
GO
insert into aa ( i,j ) values ( 0,1 ) /* here !! error that "j" doesnt exists */


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

tomino79
Starting Member

13 Posts

Posted - 2005-12-02 : 03:35:20
Yes but Command GO I cant use in ADO.
GO is internal for SQL Query Analyzer
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-02 : 03:39:48
Cant use use Alter..;Go;Insert....?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

tomino79
Starting Member

13 Posts

Posted - 2005-12-02 : 03:44:24
Yes in ADOCommand.Text you can't use "GO"


quote:
Originally posted by madhivanan

Cant use use Alter..;Go;Insert....?

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page
   

- Advertisement -