Showing posts with label 2nd. Show all posts
Showing posts with label 2nd. Show all posts

Friday, March 23, 2012

Generating scripts in SQL 2005

In SQL 2000 EM you were able to generate a script that only contained GRANT statements, (by unchecking the CREATE & DROP commands on the 2nd tab, and selecting Object Permissions on the 3rd tab). From what I can see in SQL 2005 MS you can't do this.

All that you can seem to do is generate a sciprt containing all the CREATE statements with the GRANT statement(s) after each object.

This is a bit of a pain as I want to script all the object permissions, without having to wade through hundreds of CREATE TABLE and CREATE PROCEDURE statements.

How can get just a script of GRANT statements?

Thanks.

It is not possible to generate scripts for object permissions through Management Studio like you could in Enterprise Manager. However, you can write a small SMO program to get the information the you need. This example should get you started on how to generate GRANT scripts for stored procedures.

ObjectPermissionInfo[] a = new ObjectPermissionInfo[5];

Database db = srv.Databases["pubs"];

foreach (StoredProcedure sp in db.StoredProcedures)

{

a = sp.EnumObjectPermissions();

foreach (ObjectPermissionInfo op in a)

{

Console.WriteLine("GRANT " + op.PermissionType.ToString() + " ON " + op.ObjectName.ToString() + " TO " + op.Grantee.ToString());

}

}

~Peter

|||Thanks for answering, I'll try what you suggest.

Sunday, February 26, 2012

generate report very slow?

I have posted about slow performance on report
now i create the secondary filegroup(2nd harddisk)--Account Ledge table
and put one table(684846 rows of data) from primary to secondary filegroup
but seems not improved a lot
any other idea '?You should check your query and indexes first. Maybe you are ordering
according to some expression that is not supported by an index? Maybe your
Where and Join expressions are not supported by indexes? Just by the info
you gave us it is hard to tell where the problem lies. You should include
DDL statements (Create table etc.), sample data and query you are using.
--
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"izumi" <test@.test.com> wrote in message
news:ejom%23G2KEHA.1612@.TK2MSFTNGP12.phx.gbl...
> I have posted about slow performance on report
> now i create the secondary filegroup(2nd harddisk)--Account Ledge table
> and put one table(684846 rows of data) from primary to secondary filegroup
> but seems not improved a lot
> any other idea '?
>

generate report very slow?

I have posted about slow performance on report
now i create the secondary filegroup(2nd harddisk)--Account Ledge table
and put one table(684846 rows of data) from primary to secondary filegroup
but seems not improved a lot
any other idea '?You should check your query and indexes first. Maybe you are ordering
according to some expression that is not supported by an index? Maybe your
Where and Join expressions are not supported by indexes? Just by the info
you gave us it is hard to tell where the problem lies. You should include
DDL statements (Create table etc.), sample data and query you are using.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"izumi" <test@.test.com> wrote in message
news:ejom%23G2KEHA.1612@.TK2MSFTNGP12.phx.gbl...
> I have posted about slow performance on report
> now i create the secondary filegroup(2nd harddisk)--Account Ledge table
> and put one table(684846 rows of data) from primary to secondary filegroup
> but seems not improved a lot
> any other idea '?
>

generate report very slow?

I have posted about slow performance on report
now i create the secondary filegroup(2nd harddisk)--Account Ledge table
and put one table(684846 rows of data) from primary to secondary filegroup
but seems not improved a lot
any other idea ??
You should check your query and indexes first. Maybe you are ordering
according to some expression that is not supported by an index? Maybe your
Where and Join expressions are not supported by indexes? Just by the info
you gave us it is hard to tell where the problem lies. You should include
DDL statements (Create table etc.), sample data and query you are using.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"izumi" <test@.test.com> wrote in message
news:ejom%23G2KEHA.1612@.TK2MSFTNGP12.phx.gbl...
> I have posted about slow performance on report
> now i create the secondary filegroup(2nd harddisk)--Account Ledge table
> and put one table(684846 rows of data) from primary to secondary filegroup
> but seems not improved a lot
> any other idea ??
>