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 |
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2014-10-25 : 22:35:46
|
I've a script that does select * from (select tsv=case type when 'Periodic' then case cat_cat_id when 5053 then '00001' + CHAR(9)+ 'cochase.id' + CAST(a.pbn_id as nvarchar)+ '.issue'+ CAST(a.number as nvarchar) + CHAR(9) + 'magazine ' +pbn_name + ' No.' + CAST(a.number as nvarchar) + CHAR(9) +'Non-Consumable'+ CHAR(9) + 'yes'+ CHAR(9) + CAST(pbn_tier_id as nvarchar) + CHAR(9) + 'magazine ' + '''' + pbn_name + ''' No.'+ CAST(a.number as nvarchar) + CHAR(9) + 'magazine ' + '''' + pbn_name + ''' No.'+ CAST(a.number as nvarchar) when 5054 then '00001' + CHAR(9)+ 'com.ena.store.purchase.id' + CAST(a.pbn_id as nvarchar) + CHAR(9) + 'newspaper ' +pbn_name+ CHAR(9) +'Consumable'+ CHAR(9) + 'yes'+ CHAR(9) + CAST(pbn_tier_id as nvarchar) + CHAR(9) + 'newspaper ' + '''' + pbn_name + '''' +CHAR(9) + 'newspaper ' + '''' + pbn_name + '''' endend from PUBLICATION_ISSUES_MAIN as a inner join CATEGORIES on cat_id = pbn_cat_id inner join PERIODIC_PUBLICATIONS as b on pbn_last_pbi_id = a.pbi_id where type ='Periodic' and pbn_tier_id !=0 and pbn_tier_id is not null ) as asdf What is the usage of select or this? Why select = is used? Haven't done a select = and is hard to google it .Thanks. |
|
mole999
Starting Member
49 Posts |
Posted - 2014-10-26 : 03:26:57
|
I don't know if this is the answer, but a colleague of mine did something like this in a quearya.anything As Anything"Anything" = a.anythingI think they produced similar resultsdoesn't yours produceEnd as tsv in effectMole |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-10-26 : 15:00:45
|
Yesits another way to alias the column I prefer using AS clause myself------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
sapator
Constraint Violating Yak Guru
462 Posts |
Posted - 2014-10-27 : 07:59:31
|
So it is like select tsv(case type -- blahblah ) as asdf ? |
|
|
mole999
Starting Member
49 Posts |
Posted - 2014-10-28 : 01:28:25
|
don't think so, I believeSo it is likeselect (case type-- blahblahas tsv) as asdf ?Mole |
|
|
|
|
|