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
 General SQL Server Forums
 New to SQL Server Programming
 query help

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2013-04-03 : 02:58:04

hi team,


DECLARE @VTBL TABLE (NAME VARCHAR(100)
)

INSERT INTO @VTBL (NAME)
VALUES('JACK'),
('TOM') ,
('AMAR') ,
('VIJA')

i want TO see ALL NAMES IN COLUMN wise.

LIKE

col1 col2 col3 col4
jack tom amar vijay

kindly help

challenge everything

waterduck
Aged Yak Warrior

982 Posts

Posted - 2013-04-03 : 03:16:20
http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx
Go to Top of Page

pnpsql
Posting Yak Master

246 Posts

Posted - 2013-04-03 : 03:22:37
This Topic Is No Longer Available

challenge everything
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-03 : 04:22:17
quote:
Originally posted by pnpsql

This Topic Is No Longer Available

challenge everything


does that mean your problem got sorted?

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

pnpsql
Posting Yak Master

246 Posts

Posted - 2013-04-03 : 06:12:43
no sir problem is still exists

challenge everything
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-03 : 07:06:14
whats the problem? are you trying to pivot dynamically?

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

pnpsql
Posting Yak Master

246 Posts

Posted - 2013-04-03 : 07:41:26
no i don't wanna use pivot

challenge everything
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-03 : 13:49:19
then tell what you're trying to get as output

just a single line of data doesnt explain anything for us

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

pnpsql
Posting Yak Master

246 Posts

Posted - 2013-04-06 : 07:04:41

DECLARE @VTBL TABLE (NAME VARCHAR(100)
)

INSERT INTO @VTBL (NAME)
VALUES('JACK'),
('TOM') ,
('AMAR') ,
('VIJA')

I WANT TO WRITE A QUERY THAT HAD SAME EFFECT AS BELW QUERY BUT PICKING DATA FROM @VTBL

SELECT 'JACK' , 'TOM' , 'AMAR', 'VIJA'


challenge everything
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-09 : 00:14:58
[code]
SELECT STUFF((SELECT ',' + NAME FROM @VTBL FOR XML PATH('')),1,1,'')
[/code]


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

- Advertisement -