Showing posts with label dear. Show all posts
Showing posts with label dear. Show all posts

Tuesday, March 27, 2012

Derived Column or script

Dear All,

I am pretty new to SQL2005 technologies.

I have a table like this:

Name

Code

Peter

10

Eric

20

I am interested in translation of the “code” to “job role”:

Name

Code

Job role

Peter

10

Director

Eric

20

Consultant

I have tried to use Derived Column and also script – but I am unable to get it to work.

Any hints/solution would greatly appreciate.

Best Regards, T

A simple example without NULL checking etc

In the 'Derived Column' task add a new column 'Job Role' and set the expression to be something like: -

[Code] == 10 ? "Director" : [Code] == 20 : "Consultant"

|||

Sagestore wrote:

A simple example without NULL checking etc

In the 'Derived Column' task add a new column 'Job Role' and set the expression to be something like: -

[Code] == 10 ? "Director" : [Code] == 20 : "Consultant"

Does not seem like the correct syntax, I think it should be:

[Code] == 10 ? "Director" : ( [Code] == 20 ? "Consultant" : "Unknown" )

|||

Do you have the translations stored in a table somewhere? If so, the LOOKUP component can be used.

-Jamie

|||

The translation is hardcoded which is fine.

However the number of options are more than 2 "consultan" and "director" - at least up to 5 different options.

So I need someting like:

Case 10 => Director

Case 20 => Consultant

Case 30 => Admin

Etc.

Thanks for input so far - but still im waiting for a soluion.

T

|||

Michael gave you the solution - you just need to extend it to cover all eventualities:

[Code] == 9999 ? "Something else!" : ([Code] == 30 ? "Admin" : ([Code] == 10 ? "Director" : ( [Code] == 20 ? "Consultant" : "Unknown" )))

-Jamie

|||

Thanks all of you - now I finally got it to work.

I am extremely happy with this kind of support.

Thanks again and take care, T

Thursday, March 22, 2012

Deployment problem - Insufficient Rights

Dear friends,
problem with Deployment Reports to Server.
when i click the deploy, i am getting the following error.
The permissions granted to user 'domain/machinename' are insufficient for
performing this operation.
pls assist me.
muraliIs the account your are trying to deploy with an account known on the report
server, and ifit is does it have publish rights in the report server? this
might be a the cause of this issue
"Murali" wrote:
> Dear friends,
> problem with Deployment Reports to Server.
> when i click the deploy, i am getting the following error.
> The permissions granted to user 'domain/machinename' are insufficient for
> performing this operation.
> pls assist me.
> murali|||Yes. My Account have full control on the Report Server.
How to check My Account have publish rights or not?
please reply.
"Remond" wrote:
> Is the account your are trying to deploy with an account known on the report
> server, and ifit is does it have publish rights in the report server? this
> might be a the cause of this issue
>
> "Murali" wrote:
> > Dear friends,
> >
> > problem with Deployment Reports to Server.
> >
> > when i click the deploy, i am getting the following error.
> >
> > The permissions granted to user 'domain/machinename' are insufficient for
> > performing this operation.
> >
> > pls assist me.
> >
> > murali

Sunday, March 11, 2012

Deploying reports

Dear Experts,
Is there an executable file which we could run and deploy reports?
This tool would ask which reports to deploy, where, using which datasources,
etc and it would deploy them.
Manually deploying reports through visual studio is inconvient for us and we
want anybody to do it. If there is no tool that is part of SQL 2005, can you
give us VB script, or open source code that does this?
Thanks,
Bojan NikicOn Sep 21, 4:24 pm, bojannikic <bojanni...@.discussions.microsoft.com>
wrote:
> Dear Experts,
> Is there an executable file which we could run and deploy reports?
> This tool would ask which reports to deploy, where, using which datasources,
> etc and it would deploy them.
> Manually deploying reports through visual studio is inconvient for us and we
> want anybody to do it. If there is no tool that is part of SQL 2005, can you
> give us VB script, or open source code that does this?
> Thanks,
> Bojan Nikic
The rs.exe utility should accomplish what you are looking for. This
link might be helpful.
http://weblogs.sqlteam.com/tarad/archive/2005/01/05/3944.aspx
Regards,
Enrique Martinez
Sr. Software Consultant

Sunday, February 19, 2012

Deploy Excel file that already exists on server - file isn't replaced

Dear all,

I am deploying programatically an Excel 2007 file to a SQL Server 2005 Reporting Server. The problem is that if a file with the same name already exists, that file isn't replaced. I would like the opposite to happen. I'm using the following code:

--Executable

set svr=http://w3sdwsqld1/reportserver
set src_fld="\\w3sdwsqld1\\deploy\\SAD\\ECRANS\\UPDATES_20061127_190000\\Ecrans\\AM\\Associados\\"
set dest_fld="Associados"
set script="\\w3sdwsqld1\\deploy\\SAD\ECRANS\\UPDATES_20061127_190000\\Ecrans\\AM\\Associados\\PublishReports.rss"
REM Sample: deploy.bat http://w3sdwsqld1/reportserver "\\w3sdwsqld1\\deploy\\SAD\\ECRANS\\UPDATES_20061127_190000\\Ecrans\\AM\\Associados\\" "Associados" "\\w3sdwsqld1\\deploy\\SAD\ECRANS\\UPDATES_20061127_190000\\Ecrans\\AM\\Associados\\PublishReports.rss"
for /R %src_fld% %%f in (*.xlsx) do rs -i %script% -s %svr% -v ParentFolder=%dest_fld% -v reportP="%%~nf" -v path=%src_fld%
PAUSE

--rss Code


'
' Script Variables
'
' Variables that are passed on the command line with the -v switch:
'
' (a) parentFolder - corresponds to the folder that the script creates and uses
' to contain your published reports

' (b) reportP - corresponds to the report to publish


Dim ROOT As String = "/SAD/Ecrans/Ecrans/AM"

Dim definition As [Byte]() = Nothing
Dim warnings As Warning() = Nothing
Dim parentPath As String = ROOT + "/"+ parentFolder
Dim filePath As String = path
Dim report As String = reportP


Public Sub Main()

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

'Create the parent folder
Try
rs.CreateFolder(parentFolder, ROOT,Nothing)
Console.WriteLine("Parent folder {0} created successfully", parentFolder)
Catch e As Exception

Console.WriteLine(e.Message)

End Try

'Create shared data source
'CreateSampleDataSource("Solucao_Integrada", "OLEDB-MD", "Data Source=dwareas1;Initial Catalog=SAD_Solucao_Integrada")

'Publish the sample reports
PublishReport(report)


End Sub

Public Sub CreateSampleDataSource(name As String, extension As String, connectionString As String)
'Define the data source definition.
Dim definition As New DataSourceDefinition()
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated
definition.ConnectString = connectionString
definition.Enabled = True
definition.EnabledSpecified = True
definition.Extension = extension
definition.ImpersonateUser = False
definition.ImpersonateUserSpecified = True
'Use the default prompt string.
definition.Prompt = Nothing
definition.WindowsCredentials = False

Try
rs.CreateDataSource(name, parentPath, False, definition, Nothing)
Console.WriteLine("Data source {0} created successfully", name)

Catch e As Exception
Console.WriteLine(e.Message)
End Try

End Sub

Public Sub PublishReport(ByVal reportName As String)
Try
Dim stream As FileStream = File.OpenRead(filePath + reportName + ".xlsx")
Console.WriteLine(reportName)

definition = New [Byte](stream.Length) {}
stream.Read(definition, 0, CInt(stream.Length))
stream.Close()

Catch e As IOException
Console.WriteLine(e.Message)
End Try

Try
rs.CreateResource(reportName + ".xlsx", parentPath, True, definition, "application/x-excel", Nothing)

Catch e As Exception
Console.WriteLine(e.Message)
Console.WriteLine("Failed to publish report")
End Try
End Sub
--

Any thoughts? Many thanks,

Pedro Martins

Portugal

Pedro,

Try

It looks like the paths may not be correct, use the "filePath" that you use to open the file in the below statement.

rs.CreateResource(reportName + ".xlsx", filePath, True, definition, "application/x-excel", Nothing)

I normally created my Rss script insert console write message to return values so that I can make sure I getting the corrent values.

Let me know if this helps.

Ham

|||

Ham,

The path is correct, if I deploy the file and there is no other file in the destination the file is uploaded successfully. However, If a file with the same name already exists, the new file doesn't replace the old one.

Pedro

|||

Pedro

Is the file you are trying to replace - "Open" by another application? You could use the System.IO to check on the status of this file before you try and replace.

Ham

Tuesday, February 14, 2012

deny permission to create temporary tables

Dear All,

This is my first post to this forum.

I would like to know if there is any way to restrict users from creating temp tables.

Problem: I am facing problems with lots of temporary objects getting created in my database. The users have read-only access to the database for adhoc-querying purpose through QA. Yet they are able to create temporary tables in tempdb database taking lot of resources on tempdb disk causing abnormally high growth of tempdb.

Thanks in advance.

Best Regards,

Chetan Jain

Just by executing a query, users may be using space in TempDb -that is what it is designed for. Query execution may, totally on its own volition, create temporary tables in TempDb. TempDb can growth large if the users are executing queries that require a lot of temporary storage to gather data to work with -JOINs with large resultsets, large resultsets to be sorted, etc.

Are the users creating tables 'temp' tables (starting with [#], or [##]? Or, are they creating tables?

Normally, the users' temp objects are removed from TempDb when the user connection is closed.

Perhaps the real issue is trying to determine how much space TempDb requires in order to support your users query needs, and then giving TempDb adaquate disk space.

|||

You can not stop any user from creating temprory objects in tempdb. ofcourse you can stop creating permanent table in tempdb by DDL trigger. but DDL trigger can not sense temp table.

create TRIGGER db_trg_RestrictTableChanges

ON DATABASE

FOR CREATE_Table, ALTER_Table, DROP_Table

AS

SET NOCOUNT ON

rollback

the above mentioned trigger will stop creating permanent tables in tempdb but even this can not stop temporary table

Madhu

|||Madhu's suggestion is certainly a valid one, but, unfortunately, only works in SQL 2005 (and higher).|||

Thanks for the information!. The real issue is denying explicit statements like "create table #temp" or "create table ##temp"

Best Regards,

Chetan

|||

As Madhu indicated, you can't even deny creating temp tables in SQL 2005 using the new DDL Triggers -and you also can't do so in SQL 2000.

Just make sure that the users are logging out, and then their connection will be cleared, and the space used for any temp tables will be released.