Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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 !
 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  
 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.03 seconds. Powered By: Snitz Forums 2000