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)
 how to Combine the multiple scripts

Author  Topic 

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2011-09-12 : 16:22:34
this is how i am doing now

---for the name column -----
select distinct id,name into #temp1 from table1 where name is not null
and number = 'no1'
select distinct id,name into #temp2 from table1 where name is not null
and number = 'no2'
select test.id,prod.id,test.name,prod.name from #temp1 as test Inner join #temp2 as prod on test.id = prod.id and test.name != prod.name

-- for the city column ----

Here also the same query as mentioned above but instead of having name we will put city
---------------------------

Like this i have 10 columns...instead of writing 10 times of the above script for each column is there any other way we can do it in 1 statement..

can any one help me in this..



dev

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-12 : 16:45:08
I don't understand your post. What are you trying to achieve?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-13 : 01:13:53
so you want the various column values to appear as rows (vertically) or as separte columns (horizontally)? Would appreciate if you can post the desired output format

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -