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 |
misterish
Starting Member
10 Posts |
Posted - 2012-02-16 : 16:55:00
|
Hi,I am using FOR XML PATH with a simple SELECT statement to return records within a stored proc. As long as there are records returned, this is fine, but if no records exist in the result the returned value is NULL. Instead, how can I return XML such as:<data> <error>No records found.</error></data> |
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2012-02-17 : 13:45:58
|
Have your query in a 'If Exists' block and in the else you can have something like this - SELECT 'No records found' AS 'Error'FOR XML PATH |
 |
|
|
|
|