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.
Author |
Topic |
sqldba20
Posting Yak Master
183 Posts |
Posted - 2012-12-13 : 09:49:48
|
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, ReadLOCATION, \\server\Library\, Legal, Read, ModifyThanks ! |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-12-13 : 10:00:07
|
select Type, FLocation, Account, max(nullif(NetAccess,'MISSING')), max(nullif(DBAccess,'MISSING'))from #tblDatagroup 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. |
 |
|
|
|
|
|
|