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
 General SQL Server Forums
 New to SQL Server Programming
 Error on temp data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

shanmugaraj
Posting Yak Master

219 Posts

Posted - 05/06/2013 :  08:28:27  Show Profile  Send shanmugaraj a Yahoo! Message  Reply with Quote
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') c
for xml path(''), type ) v


Error Message :
==============
Msg 8155, Level 16, State 2, Line 8
No column name was specified for column 1 of 'v'.
Msg 207, Level 16, State 1, Line 2
Invalid column name 'alais_name'.


THANKS
SHANMUGARAJ
nshanmugaraj@gmail.com

shanmugaraj
Posting Yak Master

219 Posts

Posted - 05/06/2013 :  08:57:13  Show Profile  Send shanmugaraj a Yahoo! Message  Reply with Quote
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') c
for xml path(''), type).value('.', 'VARCHAR(MAX)') str_update)

THANKS
SHANMUGARAJ
nshanmugaraj@gmail.com
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3761 Posts

Posted - 05/06/2013 :  08:59:09  Show Profile  Reply with Quote
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') c
for xml path(''), type ) v


Error Message :
==============
Msg 8155, Level 16, State 2, Line 8
No column name was specified for column 1 of 'v'.
Msg 207, Level 16, State 1, Line 2
Invalid column name 'alais_name'.


THANKS
SHANMUGARAJ
nshanmugaraj@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') c
for xml path(''), type ) v(alais_name)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 05/07/2013 :  00:21:17  Show Profile  Reply with Quote
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 MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
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