Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-05-06 : 08:28:27
|
Kindly help me to fix the error in the below query..i am getting error when i execute section : select v.alais_name from(Query ::=========select v.alais_name from(SELECT cast(c.UpdateSql as varchar(max)) alais_name FROM (select '[' +column_name +']' + ' = Replace([' + column_name + '],''"'', ''''), ' UpdateSql from information_schema.columns where table_name = 'dim_employee') cfor xml path(''), type ) vError Message :==============Msg 8155, Level 16, State 2, Line 8No column name was specified for column 1 of 'v'.Msg 207, Level 16, State 1, Line 2Invalid column name 'alais_name'.THANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
shanmugaraj
Posting Yak Master
219 Posts |
Posted - 2013-05-06 : 08:57:13
|
fixed : set @strsql=( select (SELECT cast(c.UpdateSql as varchar(max)) dfee FROM (select '[' +column_name +']' + ' = Replace([' + column_name + '],''"'', ''''), ' UpdateSql from information_schema.columns where table_name = 'dim_employee') cfor xml path(''), type).value('.', 'VARCHAR(MAX)') str_update)THANKSSHANMUGARAJnshanmugaraj@gmail.com |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-05-06 : 08:59:09
|
quote: Originally posted by shanmugaraj Kindly help me to fix the error in the below query..i am getting error when i execute section : select v.alais_name from(Query ::=========select v.alais_name from(SELECT cast(c.UpdateSql as varchar(max)) alais_name FROM (select '[' +column_name +']' + ' = Replace([' + column_name + '],''"'', ''''), ' UpdateSql from information_schema.columns where table_name = 'dim_employee') cfor xml path(''), type ) vError Message :==============Msg 8155, Level 16, State 2, Line 8No column name was specified for column 1 of 'v'.Msg 207, Level 16, State 1, Line 2Invalid column name 'alais_name'.THANKSSHANMUGARAJnshanmugaraj@gmail.com
I didn't follow the logic you are implementing. However, the syntax error can be removed by specifying the column name as shown below:....where table_name = 'dim_employee') cfor xml path(''), type ) v(alais_name) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-07 : 00:21:17
|
looks like attempt is to generate a column list from columns in dim_employee table but didnt understand purpose of replace logic though------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|