SQL Server Forums
Profile | Register | 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
 New Topic  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
52249 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
52249 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
52249 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  
 New 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.08 seconds. Powered By: Snitz Forums 2000