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
 SQL Server Administration (2000)
 multiple query in result

Author  Topic 

PatDeV
Posting Yak Master

197 Posts

Posted - 2006-08-11 : 16:47:03
declare @cmd as varchar(4000)
set @cmd =
'
select count(ID)FA00100_count from test1
go
select count(ID) IV40400_Count from test3
go
select count(ID)POP10100_count from test4
'
exec master.dbo.spSQLSMTPMail @vcTo = 'test@test.net', @vcSubject = 'Record Count',@vcQuery = @cmd

when i try to do this it gives me error saying that

Server: Msg 105, Level 15, State 1, Line 3
Unclosed quotation mark before the character string ''select count

how can i solve this

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-11 : 17:01:38
GO is always a batch terminator, even when it is inside quotes.

You can work around it this way:

declare @cmd as varchar(4000)
set @cmd =
'
select count(ID)FA00100_count from test1
g'+'o
select count(ID) IV40400_Count from test3
g'+'o
select count(ID)POP10100_count from test4
'


CODO ERGO SUM
Go to Top of Page

schuhtl
Posting Yak Master

102 Posts

Posted - 2006-08-11 : 17:03:02
you could also do the following:
'
select count(ID)FA00100_count from test1;
select count(ID) IV40400_Count from test3;
select count(ID)POP10100_count from test4
'
Go to Top of Page
   

- Advertisement -