question

David_G avatar image
David_G asked

Using WHERE in a CAST Query

Hi all, I am just wondering if anyone can please help with the following issue;

I have the following Query which runs fine, but, I need to add a WHERE filter and just can't get it to work? I am totally new to this and any help would be really appreciated. Thank you.

	SELECT Name, 
       Description,
       IsEnabled, 
       ExternalAuthProviderName,
       ExternalUserName, 
       Email, 
       CAST(XmlData AS XML).value('UserDetail[1]/Text1[1]', 'varchar(255)') AS "SummaryGroup",
       CAST(XmlData AS XML).value('UserDetail[1]/Text2[1]', 'varchar(255)') AS "SecurityGroup",
       CAST(XmlData AS XML).value('UserDetail[1]/Text3[1]', 'varchar(255)') AS "Access",
       CAST(XmlData AS XML).value('UserDetail[1]/Text4[1]', 'varchar(255)') AS "InsiderList" 
	FROM SecUser 
	WHERE   ???????? 
	ORDER BY Name
sqlwherecast
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Jon Crawford avatar image
Jon Crawford answered

well, that's how you add a WHERE clause, what are you trying to limit it to, and what is the error you are receiving? Or what is your expected result versus what you actually get?

Are you trying to limit by a value within the XML values?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.