Posted on October 29, 2009 by Raghunath Bhandari
How to create the row data as string.
If you have table row data and you need to show all the records in a single string, use the following query.
DATA:
——————–
Name
RAM
SHYAM
HARI
RITA
RESULT:
———————
Name
RAM,SHYAM,HARI,RITA
Use the following query
————————————
DECLARE @strList varchar(100)
SELECT @strList = COALESCE(@strList + ‘, ‘, ”) +
CAST(Name AS varchar(5))
FROM TABLE1
SELECT @strList
There are complex example in internet but you can [...]
Filed under: Table Row in String | Tagged: COALESCE, How to create a row data as string., MSSQL tisp, MSSQL tricks, Multiple value in single String, SQL help, String creation | 1 Comment »
Posted on October 7, 2009 by Raghunath Bhandari
How to parametrize OPENQUERY in MSSQL:
MSSQL has good feature of linked server between two different Database in same location or in remote location.
OPENQUERY helps you to execute your query in Linked server (remote) .
In linked server you can directly execute your query without OPENQUERY but the performance will be a issue.
As per my experience OPENQUERY [...]
Filed under: Parametrize OPENQUERY | Tagged: How to parametrize OPENQUERY in MSSQL, Linked server, Microsoft SQL server, MSSQL tricks, OPENQUERY, Parametrize OPENQUERY, parametrize query, Tips | Leave a Comment »
Posted on April 27, 2009 by Raghunath Bhandari
How to list all SQL Server Instance Running in Local Network:
Some time you need to see the List of other running SQL server on your network. It is so simple and easy to call from other application also.
See the example:
– ######### Query
EXEC master..xp_cmdshell ‘osql -L’
– ############ Result
NULL
Servers:
(local)
MAIL_SERVER
[...]
Filed under: SQL Server Instance Running | Tagged: How to list all SQL Server Instance Running in Local Network:, Instance Running, MS SQL server, MSSQL tips, MSSQL tricks, Raghunath Bhandari | Leave a Comment »