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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 select = usage

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 + ''''
end

end
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 queary



a.anything As Anything

"Anything" = a.anything

I think they produced similar results

doesn't yours produce

End as tsv in effect

Mole
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-10-26 : 15:00:45
Yes
its another way to alias the column
I prefer using AS clause myself

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

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 ?
Go to Top of Page

mole999
Starting Member

49 Posts

Posted - 2014-10-28 : 01:28:25
don't think so, I believe


So it is like
select (
case type
-- blahblah

as tsv

) as asdf ?


Mole
Go to Top of Page
   

- Advertisement -