Showing posts with label task. Show all posts
Showing posts with label task. Show all posts

Friday, March 30, 2012

Query/Report Help needed

Hello all,

I need to do the following task repeatedly. I have been doing it
manually until now and I am thinking if there is any way I could
automate the whole process.

Here is the task:
For a selected group of tables, I need to create an Excel file with one
worksheet per table. The worksheet contains information about the
table.

Here is an Example of Person table with fields PersonId, LastName,
FirstName ...

Column Name -> PersonId LastName FirstName ...
Type -> char char char ...
Length -> 6 50 50
Data -> P00001 Smith John ...
. P00002 Smith Joan ...You can do this from within an ActiveX Script in DTS. Select the
necessary information from INFORMATION_SCHEMA.COLUMNS, then use the
Excel automation objects to put the data into the proper cells. You can
then do the same for the actual data, using the column information that
you selected to generate a SQL statement if your tables are constantly
changing.

You should be able to find information on using the Excel automation
objects on the Microsoft website.

HTH,
-Tom.sql

Friday, March 9, 2012

query to fetch data

Hi,

I have a table with two columns Task and Employee. It lists all the
tasks and the assigned employees. The same task will have multiple
roles with an employeename or 'manager' as the data.

If I have the following data

'sales', 'john'
'sales', 'manager'
'dev', 'manager'
'make_coffee', 'manager'
'browse', 'jane'
'browse', 'manager'

I need to get the rows wherever an employee is named (sales and browse
for example) and get manager for the rest.

I can make it in two queries. Look for not manager in one and then for
manager. Is there anyway to get them in a single query?

If I need to look for 'sales', I need to get 'john' and not 'manager'.
How to do that in a single query?

Another need is to list all tasks with assigned. So for the above, I
should get the following list

'sales', 'john'
'dev', 'manager'
'make_coffee', 'manager'
'browse', 'jane'

with two queries, I will get

'sales', 'john'
'browse', 'jane'

'dev', 'manager'
'make_coffee', 'manager'

which is ok. Order/sequence is not important.

TIA,

SreelathaThe code to create and insert data
CREATE TABLE tbl (
task nvarchar(20) NOT NULL,
employee nvarchar(20) NOT NULL)
GO

insert into tbl values('sales', 'john')
insert into tbl values('sales', 'manager')
insert into tbl values('dev', 'manager')
insert into tbl values('make_coffee', 'manager')
insert into tbl values('browse', 'jane')
insert into tbl values('browse', 'manager' )
go|||SELECT Task, Coalesce(Max(NullIf(Employee, 'Manager')), 'Manager')
FROM tbl
GROUP BY Task

Mr Tea

"sreelatha" <sreelatha@.hotmail.com> wrote in message
news:1110821575.186916.111250@.z14g2000cwz.googlegr oups.com...
> Hi,
> I have a table with two columns Task and Employee. It lists all the
> tasks and the assigned employees. The same task will have multiple
> roles with an employeename or 'manager' as the data.
> If I have the following data
> 'sales', 'john'
> 'sales', 'manager'
> 'dev', 'manager'
> 'make_coffee', 'manager'
> 'browse', 'jane'
> 'browse', 'manager'
> I need to get the rows wherever an employee is named (sales and browse
> for example) and get manager for the rest.
> I can make it in two queries. Look for not manager in one and then for
> manager. Is there anyway to get them in a single query?
> If I need to look for 'sales', I need to get 'john' and not 'manager'.
> How to do that in a single query?
> Another need is to list all tasks with assigned. So for the above, I
> should get the following list
> 'sales', 'john'
> 'dev', 'manager'
> 'make_coffee', 'manager'
> 'browse', 'jane'
> with two queries, I will get
> 'sales', 'john'
> 'browse', 'jane'
> 'dev', 'manager'
> 'make_coffee', 'manager'
> which is ok. Order/sequence is not important.
> TIA,
> Sreelatha