dbTalk Databases Forums  

ExecuteSQLTask - Using the GO statement

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss ExecuteSQLTask - Using the GO statement in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Peter Newman
 
Posts: n/a

Default ExecuteSQLTask - Using the GO statement - 12-17-2003 , 07:17 AM






I have a DTS using an execute SQL Task which is importing
data into two tables linked by field 1, From previous
help, i thought it best to create a trigger on one table
and then drop the trigger after the command has
completed, rather than having 2 different SQL tasks

ExecuteSQL Task is

CREATE TRIGGER TRIG_INSERTCLIRECORD
ON t1.RegisteredUsersTable
FOR INSERT
AS
SET NOCOUNT ON
INSERT INTO t2.ClientAdminTable
VALUES ( Val1,Val2, ETC )
GO


INSERT INTO t1.RegisteredUsersTable
VALUES ( Val1, Val2 ETC)
SELECT @@rowcount AS RecordsUpdatedCount
DROP TRIGGER TRIG_INSERTCLIRECORD

I need to have the trigger set before doind the insert
query, but I get an incorrect Syntax near GO error




Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: ExecuteSQLTask - Using the GO statement - 12-17-2003 , 07:30 AM






Why not just have 2 * ExecuteSQL tasks?

1 does the parent and 1 does the child.

GO is a batch terminator.

t1 and t2 here you are using as Owners of objects. Are they not actually
databases?

This works happily in Pubs and an ExecuteSQL task

CREATE TRIGGER A ON Authors FOR INSERT
AS
select * from titles
Go
SELECT * FROM authors
GO
DROP TRIGGER A

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Peter Newman" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
I have a DTS using an execute SQL Task which is importing
data into two tables linked by field 1, From previous
help, i thought it best to create a trigger on one table
and then drop the trigger after the command has
completed, rather than having 2 different SQL tasks

ExecuteSQL Task is

CREATE TRIGGER TRIG_INSERTCLIRECORD
ON t1.RegisteredUsersTable
FOR INSERT
AS
SET NOCOUNT ON
INSERT INTO t2.ClientAdminTable
VALUES ( Val1,Val2, ETC )
GO


INSERT INTO t1.RegisteredUsersTable
VALUES ( Val1, Val2 ETC)
SELECT @@rowcount AS RecordsUpdatedCount
DROP TRIGGER TRIG_INSERTCLIRECORD

I need to have the trigger set before doind the insert
query, but I get an incorrect Syntax near GO error






Reply With Quote
  #3  
Old   
Peter Newman
 
Posts: n/a

Default Re: ExecuteSQLTask - Using the GO statement - 12-17-2003 , 07:45 AM



Alan.

The two tables are in the same database. If i was to use
two seperate ExecuteSQlTasks, how easy would it be to
rollback if either had failed to insert a record. one
table holds Company data whilst the secont holds Company
Registered user data. Both are referenced with by unique
field. I am using @@rowcount to find out if the record
was Inserted. ie if the 1st ExecuteSQLTask inserts the
record, but ExecuteSQLTask 2 failed, i would need to roll
back on ExecuteTask1..

Quote:
-----Original Message-----
Why not just have 2 * ExecuteSQL tasks?

1 does the parent and 1 does the child.

GO is a batch terminator.

t1 and t2 here you are using as Owners of objects. Are
they not actually
databases?

This works happily in Pubs and an ExecuteSQL task

CREATE TRIGGER A ON Authors FOR INSERT
AS
select * from titles
Go
SELECT * FROM authors
GO
DROP TRIGGER A

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Peter Newman" <anonymous (AT) discussions (DOT) microsoft.com
wrote in message
news:03be01c3c4a0$252c0840$a001280a (AT) phx (DOT) gbl...
I have a DTS using an execute SQL Task which is
importing
data into two tables linked by field 1, From previous
help, i thought it best to create a trigger on one
table
and then drop the trigger after the command has
completed, rather than having 2 different SQL tasks

ExecuteSQL Task is

CREATE TRIGGER TRIG_INSERTCLIRECORD
ON t1.RegisteredUsersTable
FOR INSERT
AS
SET NOCOUNT ON
INSERT INTO t2.ClientAdminTable
VALUES ( Val1,Val2, ETC )
GO


INSERT INTO t1.RegisteredUsersTable
VALUES ( Val1, Val2 ETC)
SELECT @@rowcount AS RecordsUpdatedCount
DROP TRIGGER TRIG_INSERTCLIRECORD

I need to have the trigger set before doind the insert
query, but I get an incorrect Syntax near GO error





.


Reply With Quote
  #4  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: ExecuteSQLTask - Using the GO statement - 12-17-2003 , 07:56 AM



You join the two together in a transaction

http://tinyurl.com/zmlw

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Peter Newman" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Alan.

The two tables are in the same database. If i was to use
two seperate ExecuteSQlTasks, how easy would it be to
rollback if either had failed to insert a record. one
table holds Company data whilst the secont holds Company
Registered user data. Both are referenced with by unique
field. I am using @@rowcount to find out if the record
was Inserted. ie if the 1st ExecuteSQLTask inserts the
record, but ExecuteSQLTask 2 failed, i would need to roll
back on ExecuteTask1..

-----Original Message-----
Why not just have 2 * ExecuteSQL tasks?

1 does the parent and 1 does the child.

GO is a batch terminator.

t1 and t2 here you are using as Owners of objects. Are
they not actually
databases?

This works happily in Pubs and an ExecuteSQL task

CREATE TRIGGER A ON Authors FOR INSERT
AS
select * from titles
Go
SELECT * FROM authors
GO
DROP TRIGGER A

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Peter Newman" <anonymous (AT) discussions (DOT) microsoft.com
wrote in message
news:03be01c3c4a0$252c0840$a001280a (AT) phx (DOT) gbl...
I have a DTS using an execute SQL Task which is
importing
data into two tables linked by field 1, From previous
help, i thought it best to create a trigger on one
table
and then drop the trigger after the command has
completed, rather than having 2 different SQL tasks

ExecuteSQL Task is

CREATE TRIGGER TRIG_INSERTCLIRECORD
ON t1.RegisteredUsersTable
FOR INSERT
AS
SET NOCOUNT ON
INSERT INTO t2.ClientAdminTable
VALUES ( Val1,Val2, ETC )
GO


INSERT INTO t1.RegisteredUsersTable
VALUES ( Val1, Val2 ETC)
SELECT @@rowcount AS RecordsUpdatedCount
DROP TRIGGER TRIG_INSERTCLIRECORD

I need to have the trigger set before doind the insert
query, but I get an incorrect Syntax near GO error





.




Reply With Quote
  #5  
Old   
Peter Newman
 
Posts: n/a

Default Re: ExecuteSQLTask - Using the GO statement - 12-17-2003 , 08:24 AM



Cheers Allen
Quote:
-----Original Message-----
You join the two together in a transaction

http://tinyurl.com/zmlw

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Peter Newman" <anonymous (AT) discussions (DOT) microsoft.com
wrote in message
news:09dd01c3c4a4$112d2dc0$a401280a (AT) phx (DOT) gbl...
Alan.

The two tables are in the same database. If i was to
use
two seperate ExecuteSQlTasks, how easy would it be to
rollback if either had failed to insert a record. one
table holds Company data whilst the secont holds
Company
Registered user data. Both are referenced with by
unique
field. I am using @@rowcount to find out if the record
was Inserted. ie if the 1st ExecuteSQLTask inserts the
record, but ExecuteSQLTask 2 failed, i would need to
roll
back on ExecuteTask1..

-----Original Message-----
Why not just have 2 * ExecuteSQL tasks?

1 does the parent and 1 does the child.

GO is a batch terminator.

t1 and t2 here you are using as Owners of objects.
Are
they not actually
databases?

This works happily in Pubs and an ExecuteSQL task

CREATE TRIGGER A ON Authors FOR INSERT
AS
select * from titles
Go
SELECT * FROM authors
GO
DROP TRIGGER A

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Peter Newman" <anonymous (AT) discussions (DOT) microsoft.com
wrote in message
news:03be01c3c4a0$252c0840$a001280a (AT) phx (DOT) gbl...
I have a DTS using an execute SQL Task which is
importing
data into two tables linked by field 1, From
previous
help, i thought it best to create a trigger on one
table
and then drop the trigger after the command has
completed, rather than having 2 different SQL tasks

ExecuteSQL Task is

CREATE TRIGGER TRIG_INSERTCLIRECORD
ON t1.RegisteredUsersTable
FOR INSERT
AS
SET NOCOUNT ON
INSERT INTO t2.ClientAdminTable
VALUES ( Val1,Val2, ETC )
GO


INSERT INTO t1.RegisteredUsersTable
VALUES ( Val1, Val2 ETC)
SELECT @@rowcount AS RecordsUpdatedCount
DROP TRIGGER TRIG_INSERTCLIRECORD

I need to have the trigger set before doind the
insert
query, but I get an incorrect Syntax near GO error





.



.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.