.Net Basic

This blogs gives introduction to C#.NET programming for beginners. This blogs assumes that you have no programming experience whatsoever. It's a lot easier than you think, and can be a very rewarding hobby!after Refer this blog

07 May 2010

Multiple rows in a single row with separator in SqlServer

Here is a simple way to make a single row value from multiple rows with a separator in SqlServer. I have a table like the following…
Table Name: People
Column name :ID,Name


Now I need the ‘Name’ column values where matching the value of ‘aaaa’ in to a single row. For this I have tried to make a query. Just use the following query to get the solution. declare @res varchar(1000) select @res = coalesce(@res + ',', '') +Name from people WHERE Name = 'aaaa' select @res

How to join tables from different servers?

EXEC sp_addlinkedserver SERVER_01
GO

/* The following command links 'sa' login on SERVER_02 with the 'sa' login of SERVER_01*/

EXEC sp_addlinkedsrvlogin @rmtsrvname = 'SERVER_01', @useself = 'false', @locallogin = 'sa', @rmtuser = 'sa', @rmtpassword = 'sa password of SERVER_01'

GO

SELECT a.title_idFROM SERVER_01.pubs.dbo.titles aINNER JOIN SERVER_02.pubs.dbo.titles bON a.title_id = b.title_idGO

Labels: ,