Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 help with query output
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

emmim44
Yak Posting Veteran

65 Posts

Posted - 07/17/2012 :  04:50:27  Show Profile  Reply with Quote
a

Edited by - emmim44 on 07/20/2012 08:30:50

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 07/17/2012 :  09:48:39  Show Profile  Reply with Quote
if you want column value you need to use dynamic sql for that. get name of column in a variable and append it to query as a string. then use EXEC or sp_executesql to execute it

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

Go to Top of Page

emmim44
Yak Posting Veteran

65 Posts

Posted - 07/17/2012 :  10:47:00  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

if you want column value you need to use dynamic sql for that. get name of column in a variable and append it to query as a string. then use EXEC or sp_executesql to execute it

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




I am kinna confused. Do you have a sample?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 07/17/2012 :  10:58:49  Show Profile  Reply with Quote
how is data present in unsaccountb table. does it have column storing name and another column storing value?

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

Go to Top of Page

emmim44
Yak Posting Veteran

65 Posts

Posted - 07/17/2012 :  16:23:04  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

how is data present in unsaccountb table. does it have column storing name and another column storing value?

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



This is the problem area..As seen below, the query outputs the unsaccountB tbl column name instead of the unsaccountB tbl column value. "CanonicalName " is one of the column name in unsaccountB tbl not the value...
dw.[OldValue] | newVal=
FINSOFT/FINSOFT/Özlem Karaman | CanonicalName

Also here is some data on unsaccountB tbl:

Edited by - emmim44 on 07/20/2012 08:31:12
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 07/17/2012 :  22:58:35  Show Profile  Reply with Quote
please post within code tags when you give some data. otherwise its quite difficult to find out the column names with values

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

Go to Top of Page

emmim44
Yak Posting Veteran

65 Posts

Posted - 07/18/2012 :  05:08:40  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

please post within code tags when you give some data. otherwise its quite difficult to find out the column names with values

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





It is already between "code" tags...

Edited by - emmim44 on 07/18/2012 05:09:31
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000