Showing posts with label names. Show all posts
Showing posts with label names. Show all posts

Friday, March 30, 2012

Output Column names in each Row along with the row Value

Hello,

I was wondering if anyone can help me figure something out.
Is it possible to do a querey in MS SQL server and have the results
returned so that each result in each row is preceeded by the column
name?

eg. instead of usual output -colName1, colValue1,
colName2,colValue2,colName3,colValue3 ?

Also I would like to only have this for certain columns ie in the
above example only for columns 2 and 3

Thank you! :-)

YasOn Jun 29, 3:09 pm, Yas <yas...@.gmail.comwrote:

Quote:

Originally Posted by

Hello,
>
I was wondering if anyone can help me figure something out.
Is it possible to do a querey in MS SQL server and have the results
returned so that each result in each row is preceeded by the column
name?
>
eg. instead of usual output -colName1, colValue1,
colName2,colValue2,colName3,colValue3 ?
>
Also I would like to only have this for certain columns ie in the
above example only for columns 2 and 3
>
Thank you! :-)
>
Yas


Not sure what you are actually looking at

create table #temp (col1 int, col2 int , col3 varchar(10))
insert into #temp values (1,10,'abcd')
insert into #temp values (2,20,'efgh')

select col1, ' col2:'+cast(col2 as varchar(10))+ '-col3:'+col3 as
col23
from #temp

drop table #temp|||On 29 Jun, 14:27, M A Srinivas <masri...@.gmail.comwrote:

Quote:

Originally Posted by

On Jun 29, 3:09 pm, Yas <yas...@.gmail.comwrote:
>
>
>

Quote:

Originally Posted by

Hello,


>

Quote:

Originally Posted by

I was wondering if anyone can help me figure something out.
Is it possible to do a querey in MS SQL server and have the results
returned so that each result in each row is preceeded by the column
name?


>

Quote:

Originally Posted by

eg. instead of usual output -colName1, colValue1,
colName2,colValue2,colName3,colValue3 ?


>

Quote:

Originally Posted by

Also I would like to only have this for certain columns ie in the
above example only for columns 2 and 3


>

Quote:

Originally Posted by

Thank you! :-)


>

Quote:

Originally Posted by

Yas


>
Not sure what you are actually looking at
>


Hi, thanks for the response. Basically I want to have a query in a DTS
package that outputs to a text file with each line containing 1 row of
results.
What I would like to have is on each line before a given value is
written the column header for that value is also written. the file is
a semicolon delimmeted file so it would look something like this...

col1Name;value1;col2Name;value2;col3Name;value3... .etc

so...
FirstName;firstNameValue;SecondName;secondNameValu e;Occupation;occupationValue..etc

Now I can just do...
SELECT 'FirstName', firstName, 'SecondName', secondName,
'Occupation' occupation
FROM Table1
Which would output the table I want with the values between '' showing
up in unnamed columns... BUT is there a better way of doing this?
especially as I want to do this in a DTS package Export Data which
esentially has a create table type command to ouptut to a text file
and throws errors that destination column name not defined.

Thanks :-)

Quote:

Originally Posted by

create table #temp (col1 int, col2 int , col3 varchar(10))
insert into #temp values (1,10,'abcd')
insert into #temp values (2,20,'efgh')
>
select col1, ' col2:'+cast(col2 as varchar(10))+ '-col3:'+col3 as
col23
from #temp
>
drop table #temp

|||Yas (yasar1@.gmail.com) writes:

Quote:

Originally Posted by

Now I can just do...
SELECT 'FirstName', firstName, 'SecondName', secondName,
'Occupation' occupation
FROM Table1
Which would output the table I want with the values between '' showing
up in unnamed columns... BUT is there a better way of doing this?


That would indeed be the way to do it.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||On 29 Jun, 23:38, Erland Sommarskog <esq...@.sommarskog.sewrote:

Quote:

Originally Posted by

Yas (yas...@.gmail.com) writes:

Quote:

Originally Posted by

Now I can just do...
SELECT 'FirstName', firstName, 'SecondName', secondName,
'Occupation' occupation
FROM Table1
Which would output the table I want with the values between '' showing
up in unnamed columns... BUT is there a better way of doing this?


>
That would indeed be the way to do it.


Thanks! :-)

Tuesday, March 20, 2012

Other Replication Providers

Can anyone tell me the names of some non-Microsoft Replication providers? I
have found a company called Peer Direct, but would like to see what other
alternatives exist for replication.
Thanks in advance
Ron L
What precisely are you trying to accomplish.
Sometimes people run to 3rd party products because of problems they have
with native SQL Server replication, when a support call to PSS could solve
the problem.
Last I heard the DataMirror licenses where $30k.
"Ron L" <ronl@.bogus.Address.com> wrote in message
news:#f2fIaptEHA.2596@.TK2MSFTNGP15.phx.gbl...
> Can anyone tell me the names of some non-Microsoft Replication providers?
I
> have found a company called Peer Direct, but would like to see what other
> alternatives exist for replication.
> Thanks in advance
> Ron L
>
|||Paul
Thanks for the suggestion, I will take a look at it.
Ron L
"Paul Ibison" <Paul.Ibison@.Pygmalion.Com> wrote in message
news:177d01c4b698$1d3eb6b0$a501280a@.phx.gbl...
> DataMirror is occasionally mentioned in this newsgroup
> (http://www.datamirror.com/products/tserver/) although I
> haven't implemented it myself.
> Rgds,
> Paul Ibison (SQL Server MVP)
>
|||Hilary
Thanks for the response. We have a database that is being replicated to
2 other sites currently and will probably add anywhere from 1 to 15 sites
over the next few years. As I mentioned before, some of the sites are
disconnected for extended periods of times. In setting up and maintaining
the merge replication we have in place, we have found a number of issues
with replication that concern us from the point of long-term data transfer.
One of these issues is the fact that MS seems to strongly suggest that a
snapshot be periodically created and pushed to existing subscribers.
Another is how the retention and re-initialization procedures work. We are
not always in a situation where we can have all of the subscribers connected
at the same time to re-initialize them.
Ron L
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:O%23UgeCstEHA.1452@.TK2MSFTNGP11.phx.gbl...
> What precisely are you trying to accomplish.
> Sometimes people run to 3rd party products because of problems they have
> with native SQL Server replication, when a support call to PSS could solve
> the problem.
> Last I heard the DataMirror licenses where $30k.
> "Ron L" <ronl@.bogus.Address.com> wrote in message
> news:#f2fIaptEHA.2596@.TK2MSFTNGP15.phx.gbl...
> I
>

Saturday, February 25, 2012

osql :r filenames with spaces

osql :r doesn't seem to like file names with spaces. Don't want to have to
use shortnames if I don't have to.
What's the fix?
Thanks
Martin
Hi,
Use double quotes (") while mentioning the file names with spaces (special
charecters)
Sample:-
osql -Usa -Sa266uss\harisql -Phari -Q"select * from
master..sysobjects" -o"c:\sys objects.txt"
Thanks
Hari
MCDBA
"Martin" <x@.y.z> wrote in message
news:e67N1YkaEHA.2340@.TK2MSFTNGP09.phx.gbl...
> osql :r doesn't seem to like file names with spaces. Don't want to have
to
> use shortnames if I don't have to.
> What's the fix?
> Thanks
> Martin
>