SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SQL Query Help !
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sqldba20
Posting Yak Master

183 Posts

Posted - 12/13/2012 :  09:49:48  Show Profile  Reply with Quote
Need help with a SQL:

create table #tblData
(Type varchar(10),
FLocation varchar(100),
Account varchar(50),
NetAccess varchar(50),
DBAccess varchar(50))

insert into #tblData values ('REPORTS','\\server\Library\','Admin','MISSING','Read')
insert into #tblData values ('REPORTS','\\server\Library\','Admin','Modify','MISSING')

insert into #tblData values ('LOCATION','\\server\Library\','Legal','MISSING','Modify')
insert into #tblData values ('LOCATION','\\server\Library\','Legal','Read','MISSING')


In the above case there are 2 records for each Type, FLocation and Account.

I would like the output to be:

REPORTS, \\server\Library\, Admin, Modify, Read
LOCATION, \\server\Library\, Legal, Read, Modify



Thanks !

Edited by - sqldba20 on 12/13/2012 09:51:12

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/13/2012 :  10:00:07  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
select Type, FLocation, Account, max(nullif(NetAccess,'MISSING')), max(nullif(DBAccess,'MISSING'))
from #tblData
group by Type, FLocation, Account


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000