Wednesday, March 28, 2012

saving output from multiple queries

Greetings,

I have what seems a simple problem...
I want to save the output from the following queries in 1 file in
'SQL Query Analyser', but I can only save each 'grid' separately.
I have about 30 queries in total. 'Messages' tells me the number of
rows affected but I need the data.

So can I save all the grids together at the same time in 1 file ?

Thanks
Mike

PRINT 'HEAT 3510'

SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
d.tpitdaydate AS Payroll_Date,
c.tishactualenddate AS TS_end_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050614'
and (d.tpitdaydate > '20050614'
or d.tpitdaydate IS null)
order by d.tpitdaydate

SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
c.tishactualenddate AS TS_end_date,
g.thisdaydate AS TSH_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
INNER join timesheethistory g ON g.thistishguid = c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050619'
order by g.thisdaydate

PRINT 'HEAT 3213'Try the Query menu: Results to File (or Results to Text).

Simon|||You can save it to one file .
there may be a menutitle at sql query analyser
that is named something like "Query"
in there you have the option to select how you want your
result.
there you can select, that you get results in a file.
by starting the queries you will be asked where to save
the file.

> Greetings,
> I have what seems a simple problem...
> I want to save the output from the following queries in 1 file in
> 'SQL Query Analyser', but I can only save each 'grid' separately.
> I have about 30 queries in total. 'Messages' tells me the number of
> rows affected but I need the data.
> So can I save all the grids together at the same time in 1 file ?
> Thanks
> Mike
> PRINT 'HEAT 3510'
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
> d.tpitdaydate AS Payroll_Date,
> c.tishactualenddate AS TS_end_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050614'
> and (d.tpitdaydate > '20050614'
> or d.tpitdaydate IS null)
> order by d.tpitdaydate
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> c.tishactualenddate AS TS_end_date,
> g.thisdaydate AS TSH_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> INNER join timesheethistory g ON g.thistishguid = c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050619'
> order by g.thisdaydate
> PRINT 'HEAT 3213'|||Simon Hayes schreef:

> Try the Query menu: Results to File (or Results to Text).
> Simon

purrfect !

No comments:

Post a Comment