Q: Data Set fields gone after refreshing the fields in query designer - SSRS VS2017 for working Report, DataSet fields gone after refreshing the fields in query designer. It worked after Undo. But when i try to copy paste the same query in new report, the data fields are not showing in dataset.

A: This typically occurs when a query has a syntax error that SSMS doesn't mind, but RS can't parse. For instance - duplicate column names in the output or a timeout exception come to mind. If you post the query, we can help you debug a bit more - otherwise, I would go over your query with a fine-tooth comb, and see if you can get an error message out of RS.

A: *

*Have an alias for each column in your final SELECT query using the AS clause. This way SSRS quickly detects the fields and you won't lose your fields even on changing the query.

*Also, you mentioned that you are getting error with the declare construct. This error mostly happens when you already have a query parameter mapped to an SSRS report parameter but your query again assigns it a value with the declare statement


For ex-
If you have an @Id parameter mapped to a report parameter Id , and in your dataset query, you do-  DECLARE @Id=4 this results in the error that you mentioned in the comments.
