terça-feira, 19 de junho de 2012

Reporting services subscriptions on SQL Express

When trying to sign a report to be sent automatically via email, I received the following message: The "Signatures for reports" not supported in this edition of Reporting Services. Before any more detailed research I realized I was pointing to a server whose version was SQLServer Express. This version does not have SQLServer Agent, which is who controls the actions of scheduling and execution schedule, among other things, SQLServer. Thus, some attention solve the problem. It was enough to point to the production server, and it opened normally. If you also deal with different versions of SQL Server: stay tuned!


Google translation from original at Portuguese version.

Assinaturas do Reporting services no SQL Express

Ao tentar assinar um relatório para envio automático via email, recebi a seguinte mensagem: O recurso "Assinaturas para relatórios" não tem suporte nesta edição do Reporting Services. Antes de qualquer pesquisa mais detalhada percebi que estava apontando para um servidor cujo SQLServer era a versão Express. Esta versão não possui SQLServer Agent, que é quem controla as ações de agendamento e execução programada, entre outras coisas, do SQLServer. Assim, um pouco de atenção resolve o problema. Bastou apontar para o servidor de produção e o serviço abriu normalmente. Se você também lida  com diferentes versões do SQL Server: fique atento!

sexta-feira, 15 de junho de 2012

Explicitly set the length of the variables

I was working on a function wich should return me a due date for a billing system, when all of a suden, an error show up: I cannot convert a date in string to a datetime. An excerpt of the code is:


declare @mes varchar = cast(month(getdate()) as varchar),
@ano varchar = cast(year(getdate()) as varchar),
@dia varchar = cast(day(getdate()) as varchar);



select convert(smalldatetime, @ano + '.'  + @mes + '.' + @dia  , 102 ) -- Error here!!!


The result string from  @ano + '.'  + @mes + '.' + @dia was  '2.6.15' (I am using the ANSI format, i.e. 102). I could figure out that issuing a simple select statement:
select @ano + '.'  + @mes + '.' + @dia, cast(year(getdate()) as varchar) 

The solution: explicitly set the length of the variables. Look down here:

declare @mes varchar(2) = cast(month(getdate()) as varchar),
@ano varchar(4) = cast(year(getdate()) as varchar),
@dia varchar(2) = cast(day(getdate()) as varchar);

Finally, the goes (back) on...