Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Monday, March 26, 2012

How can I process my cube from a windows form?

I prefer c#.net but if you only know VB.net that would be helpful. Even if you know how to do it from a command prompt, that would be very helpful. I am using SSAS2005.

This is the xmla file that it generates when I go to script the command, I dont know if this helps.


Code Snippet

<Batch xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
'>http://schemas.microsoft.com/analysisservices/2003/engine">http://schemas.microsoft.com/analysisservices/2003/engine">
; <Process xmlns:xsd="http://www.w3.org/2001/XMLSchemahttp://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A< A>>" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instancehttp://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A< A>>" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2http://schemas.microsoft.com/analysisservices/2003/engine/2">http://schemas.microsoft.com/analysisservices/2003/engine/2</A< A>>" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2">
'>http://schemas.microsoft.com/analysisservices/2003/engine/2/2">http://schemas.microsoft.com/analysisservices/2003/engine/2/2">
; <Object>
<DatabaseID>MRSTATSanalysis</DatabaseID>
<CubeID>MRSTATS</CubeID>
</Object>
<Type>ProcessFull</Type>
<WriteBackTableCreation>UseExisting</WriteBackTableCreation>
</Process>
</Batch>

Thank you all.

I found this code in a different thread, but it should work here. This code reads the xmla from a file.

Code Snippet

using System.IO;
using Microsoft.AnalysisServices.AdomdClient;

public class XmlaExecutor
{
public static void Main(string[] args)
{
TextReader tr = File.OpenText(args[0]);
string xmla = tr.ReadToEnd();
tr.Close();
AdomdConnection cn = new AdomdConnection("Data Source=localhost");
cn.Open();
AdomdCommand cmd = cn.CreateCommand();
cmd.CommandText = xmla;
cmd.ExecuteNonQuery();
cn.Close();
}
}

|||Thanks a lot, that worked perfectly. The only thing I had to do was add the .NET reference to Microsoft.AnalysisServices.AdomdClient.|||

You can also use AMO (Microsoft.AnalysisServices.dll), the management object model for Analysis Services 2005. ADOMD.NET (Microsoft.AnalysisServices.AdomdClient.dll) is mostly for querying data, while AMO is for management tasks like process, backup, restore, create, delete objects.

Quick info on AMO: http://adriandu.spaces.live.com/

Sample AMO code to create and process a partition: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=516918&SiteID=1

Adrian Dumitrascu

Monday, March 19, 2012

How can I list NTLM permissions on a database

Hi folks,
does anybody know a tool or command/sql statement to list all permissions
which are set on a given database. The database has been created years ago
using network authetication. What I am looking for is something like dumpsec
for NTFS.
Thanks
AndreHi Andre,
Did you mean that you would like to list all permissions specified to the
database users on a given database?
You may try the following statement:
USE <database_name>
Go
select distinct l.name as grantee_name, p.permission_name from
sys.database_permissions as p join sys.database_principals as l
ON p.grantee_principal_id = l.principal_id
order by grantee_name
Hope this helps. If you have any other questions or concerns, please feel
free to let me know.
Best regards,
Charles Wang
Microsoft Online Community Support
======================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================|||Hi,
I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.
Best regards,
Charles Wang
Microsoft Online Community Support
======================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================|||Charles,
thanks a lot for your quick reply to my issue.
The SQL query you provided did not work. I assume it was meant for SQL
Server 2005. Sorry, in my post I forgot to mention the used version (SQL
Server 2000). However, after searching the internet for a way to dump the
permissions, I found DumpSQLSec. A nice handy tool which dumps a lot of
informations about a database table. See
http://www.sqlservercentral.com/columnists/cmiller/dumpsqlpermissions.asp
for details.
Again, thanks for your support
Andre
"Charles Wang[MSFT]" <changliw@.online.microsoft.com> schrieb im Newsbeitrag
news:tFyfyC2zHHA.5836@.TK2MSFTNGHUB02.phx.gbl...
> Hi,
> I am interested in this issue. Would you mind letting me know the result
> of
> the suggestions? If you need further assistance, feel free to let me know.
> I will be more than happy to be of assistance.
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> ======================================================> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from this issue.
> ======================================================> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> ======================================================>|||Hi Andre,
Thank you for your reply and the detailed additional feedback on how you
were successful in resolving this issue. This information has been added to
Microsoft's database. Your solution will benefit many other users, and we
really value having you as a Microsoft customer.
If you have any other questions or concerns, please do not hesitate to
contact us. It is always our pleasure to be of assistance.
Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
======================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================

How can I list NTLM permissions on a database

Hi folks,
does anybody know a tool or command/sql statement to list all permissions
which are set on a given database. The database has been created years ago
using network authetication. What I am looking for is something like dumpsec
for NTFS.
Thanks
AndreHi Andre,
Did you mean that you would like to list all permissions specified to the
database users on a given database?
You may try the following statement:
USE <database_name>
Go
select distinct l.name as grantee_name, p.permission_name from
sys.database_permissions as p join sys.database_principals as l
ON p.grantee_principal_id = l.principal_id
order by grantee_name
Hope this helps. If you have any other questions or concerns, please feel
free to let me know.
Best regards,
Charles Wang
Microsoft Online Community Support
========================================
==============
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
========================================
==============
This posting is provided "AS IS" with no warranties, and confers no rights.
========================================
==============|||Hi,
I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.
Best regards,
Charles Wang
Microsoft Online Community Support
========================================
==============
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
========================================
==============
This posting is provided "AS IS" with no warranties, and confers no rights.
========================================
==============|||Charles,
thanks a lot for your quick reply to my issue.
The SQL query you provided did not work. I assume it was meant for SQL
Server 2005. Sorry, in my post I forgot to mention the used version (SQL
Server 2000). However, after searching the internet for a way to dump the
permissions, I found DumpSQLSec. A nice handy tool which dumps a lot of
informations about a database table. See
http://www.sqlservercentral.com/col...permissions.asp
for details.
Again, thanks for your support
Andre
"Charles Wang[MSFT]" <changliw@.online.microsoft.com> schrieb im Newsbeit
rag
news:tFyfyC2zHHA.5836@.TK2MSFTNGHUB02.phx.gbl...
> Hi,
> I am interested in this issue. Would you mind letting me know the result
> of
> the suggestions? If you need further assistance, feel free to let me know.
> I will be more than happy to be of assistance.
> Best regards,
> Charles Wang
> Microsoft Online Community Support
> ========================================
==============
> When responding to posts, please "Reply to Group" via
> your newsreader so that others may learn and benefit
> from this issue.
> ========================================
==============
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> ========================================
==============
>|||Hi Andre,
Thank you for your reply and the detailed additional feedback on how you
were successful in resolving this issue. This information has been added to
Microsoft's database. Your solution will benefit many other users, and we
really value having you as a Microsoft customer.
If you have any other questions or concerns, please do not hesitate to
contact us. It is always our pleasure to be of assistance.
Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
========================================
=============
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...t/default.aspx.
========================================
==============
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
========================================
==============
This posting is provided "AS IS" with no warranties, and confers no rights.
========================================
==============

Friday, March 9, 2012

How can I insert the results from an EXEC command

Declare @.pTable varchar(30)
DECLARE @.TotRec integer
select @.pTable = 'Salaires'
SELECT @.TotRec EXEC ('SELECT Count(*) FROM ' + @.pTable)
GO
Print @.TotRec
How can I insert the results from an EXEC command?[QUOTE][SIZE=1]Originally posted by ericjean
Declare @.pTable varchar(30)
DECLARE @.TotRec integer
select @.pTable = 'Salaires'
SELECT @.TotRec = EXEC ('SELECT Count(*) FROM ' + @.pTable)
GO
Print @.TotRec

Like that is not correct!|||Unless you are just presenting a simplified example, there is no need to use dynamic sql to get rowcounts. You can look them up directly in the system tables (sysindexes where indid in (0, 1)):
-------------
set @.TotRec =
(select sysindexes.Rowcnt
from sysobjects
inner join sysindexes on sysobjects.id = sysindexes.id
where sysobjects.name = @.pTable and sysobjects.xtype = 'U' and sysindexes.indid in (0, 1)

Print @.TotRec
-------------

blindman|||Good idea!

Thank's|||I need to do like this

Declare @.pTable varchar(30)
DECLARE @.tmp integer
select @.pTable = 'Salaires'
SELECT @.tmp = exec('SELECT count(*) FROM ' + @.pTable + ' WHERE ID = 2)|||Declare @.pTable varchar(30)
DECLARE @.tmp integer
select @.pTable = 'Salaires'
SET @.tmp = ('SELECT count(*) FROM ' + @.pTable + ' WHERE ID = 2)

@.tmp now has the count of that table

Friday, February 24, 2012

How can I get rid of the comma in a company name by using sql command?

For example: company_name: ABC company, inc.

I want to get rid of the comma, replace by a space. How the query should be write?

Thanks

replace(ColumnName,',',' ')

example

select replace('ABC,ZXX',',',' ')

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||Thank You!!!

Sunday, February 19, 2012

How can i get a return code of 1 for an osql command which has a lower severity..

I am running the following OSQL command and capturing the return code
for the error .Whenver i have an error like server not exists or uable
to login I get a return code of 1 for the %ERRORLEVEL%.However
whenever I have an errorof a wrong dbcompatibility error the retun
code id 1 even though sql returns an iformation message from OSQL that
the right copatibilty levels are 60,70 and 80.How can i get OSQL to
return the right return code whenver a error of this type occurrs from
batch mode sql.The OSQL i am running from the batch is

osql -S%SrvName% -U%Username% -P%Userpswd% -n -w 132 -d%DBname%
-Q%sqlcmd% -o%Dirrpt%\%DBname%_%SPname%.txt
ECHO %errorlevel% >> %logbatch%
IF %ERRORLEVEL% NEQ 0 Goto SQLError

sqlcms is exec sp_dbcompatibiltylevel srvrname, dbname 80

Thanks in anticipation.

Ajay[posted and mailed, please reply in news]

Ajay Garg (ajayz90@.hotmail.com) writes:
> I am running the following OSQL command and capturing the return code
> for the error .Whenver i have an error like server not exists or uable
> to login I get a return code of 1 for the %ERRORLEVEL%.However
> whenever I have an errorof a wrong dbcompatibility error the retun
> code id 1 even though sql returns an iformation message from OSQL that
> the right copatibilty levels are 60,70 and 80.How can i get OSQL to
> return the right return code whenver a error of this type occurrs from
> batch mode sql.The OSQL i am running from the batch is
> osql -S%SrvName% -U%Username% -P%Userpswd% -n -w 132 -d%DBname%
> -Q%sqlcmd% -o%Dirrpt%\%DBname%_%SPname%.txt
> ECHO %errorlevel% >> %logbatch%
> IF %ERRORLEVEL% NEQ 0 Goto SQLError
> sqlcms is exec sp_dbcompatibiltylevel srvrname, dbname 80

Here is a simple example that illustrates:

E:\temp>osql -E -n -Q "EXIT (SELECT 47)"

----
47

(1 row affected)

E:\temp>echo %ERRORLEVEL%
47

E:\temp
By putting the entire SQL batch within EXIT(), OSQL will return the
value of the last result set to the command-line environment.

For details, see the topic on OSQL in Books Online.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog <sommar@.algonet.se> wrote in message news:<Xns9402EF532A497Yazorman@.127.0.0.1>...
> [posted and mailed, please reply in news]
> Ajay Garg (ajayz90@.hotmail.com) writes:
> > I am running the following OSQL command and capturing the return code
> > for the error .Whenver i have an error like server not exists or uable
> > to login I get a return code of 1 for the %ERRORLEVEL%.However
> > whenever I have an errorof a wrong dbcompatibility error the retun
> > code id 1 even though sql returns an iformation message from OSQL that
> > the right copatibilty levels are 60,70 and 80.How can i get OSQL to
> > return the right return code whenver a error of this type occurrs from
> > batch mode sql.The OSQL i am running from the batch is
> > osql -S%SrvName% -U%Username% -P%Userpswd% -n -w 132 -d%DBname%
> > -Q%sqlcmd% -o%Dirrpt%\%DBname%_%SPname%.txt
> > ECHO %errorlevel% >> %logbatch%
> > IF %ERRORLEVEL% NEQ 0 Goto SQLError
> > sqlcms is exec sp_dbcompatibiltylevel srvrname, dbname 80
> Here is a simple example that illustrates:
> E:\temp>osql -E -n -Q "EXIT (SELECT 47)"
> ----
> 47
> (1 row affected)
> E:\temp>echo %ERRORLEVEL%
> 47
> E:\temp>
> By putting the entire SQL batch within EXIT(), OSQL will return the
> value of the last result set to the command-line environment.
> For details, see the topic on OSQL in Books Online.

I noticed someting even more interesting.Even though the return code
was 0
when there was an error the job on sql server which actually failed
showed that it ran sucessfully.Even though when i run the job as an
Xp_cmdshell command on the sql server it shows that it failed what
could be the reason that it behaves that way?

Thanks in anticipation.

Ajay|||Ajay Garg (ajayz90@.hotmail.com) writes:
> I noticed someting even more interesting.Even though the return code
> was 0
> when there was an error the job on sql server which actually failed
> showed that it ran sucessfully.Even though when i run the job as an
> Xp_cmdshell command on the sql server it shows that it failed what
> could be the reason that it behaves that way?

I'm sorry, but I don't follow. Could you clarify with an example?

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp