Usuario
Error en sentencia SELECT

Pregunta
-
Buenas noches,
Verán me encuentro creando una consulta para generar un XML, he llegado a un punto donde SQL me lanza error al parecer es porque el alias es muy grande, me lanza este error:
The identifier that starts with '' is too long. Maximum length is 128.
Este es el query, el cual arma los nodos:
SELECT 'ReviewingPosting/PartyPosting/PartyTaxSorEntityPosting/RegistrationAddressPosting/CountryPosting/ValidationCodePosting/@listAgencyName' = 'Test' FOR XML PATH('')
Por favor tiene alguna idea de que se puede hacer? Gracias.
Todas las respuestas
-
Hola AlbertoKR:
De tu pregunta no se entiende muy bien lo que quieres hacer, no obstante:
declare @xml xml; set @xml = 'ReviewingPosting/PartyPosting/PartyTaxSorEntityPosting/RegistrationAddressPosting/CountryPosting/ValidationCodePosting/@listAgencyName=Test' select @xml for xml path;
Salida
- Propuesto como respuesta Pedro Alfaro jueves, 7 de marzo de 2019 17:39
-
Buen día AlbertoKR,
Por lo que veo estás instanciando mal el Alias. Utilizas el "=" en vez de "as"
Probá de ésta forma...
SELECT 'ReviewingPosting/PartyPosting/PartyTaxSorEntityPosting/RegistrationAddressPosting/CountryPosting/ValidationCodePosting/@listAgencyName' as 'Test' FOR XML PATH('')
Saludos!
_____________________________________________________
Francisco Ingaramo - Administrador de Base de Datos
Microsoft Certified Professional
blog: https://dbownerblog.wordpress.com/
in: https://www.linkedin.com/in/francisco-ingaramo-000500aa/
-
Gracias por sus respuestas, espero obtener como salida el resultado de lo siguiente:
SELECT 'ReviewingXX/PartyXX/PartyTaxSorEntityXX/RegistrationAddressXX/CountryXX/ValidationCodeXX/@listAgencyName' = 'Test' FOR XML PATH('')
Como mis nombres de nodos son muy grandes sale ese error.
Alguna idea? Gracias
-
Y si ubicas 'Test' primero, sigue siendo una alternativa lógica para tu problema?
SELECT 'Test' = 'ReviewingPosting/PartyPosting/PartyTaxSorEntityPosting/RegistrationAddressPosting/CountryPosting/ValidationCodePosting/@listAgencyName' FOR XML PATH('')
-
Que tal,
Test es el valor que vendría de la base de datos.
Salida esperada:
SELECT 'ReviewingXX/PartyXX/PartyTaxSorEntityXX/RegistrationAddressXX/CountryXX/ValidationCodeXX/@listAgencyName' = 'Test' FOR XML PATH('')
Salida con error:
SELECT 'ReviewingPosting/PartyPosting/PartyTaxSorEntityPosting/RegistrationAddressPosting/CountryPosting/ValidationCodePosting/@listAgencyName' = 'Test' FOR XML PATH('')
Saludos