Showing posts with label management. Show all posts
Showing posts with label management. Show all posts

Friday, March 23, 2012

How to use SQL Server Management Studio to save existing SP to source safe?

Wiith SQL Server Management Studio(SQL Server 2005 tools), you can create a project and solution and connect to SourceSafe, then create SQL scripts.These scripts will be able to be checked in/out SourceSafe.

Question is: For existing SQL Server 2000 database, how can I add all existing Stored Procedure to this solution/project and then be able to use sourcesafe to maintain the SP code history?

What I would do is create a database solution/project for each instance in VS2005, script out the objects from the database server and add them to the solution, add the solution to your source control.

Wednesday, March 21, 2012

How to use SQL Server Management Studio to save existing SP to source safe?

Wiith SQL Server Management Studio(SQL Server 2005 tools), you can create a project and solution and connect to SourceSafe, then create SQL scripts.These scripts will be able to be checked in/out SourceSafe.

Question is: For existing SQL Server 2000 database, how can I add all existing Stored Procedure to this solution/project and then be able to use sourcesafe to maintain the SP code history?

What I would do is create a database solution/project for each instance in VS2005, script out the objects from the database server and add them to the solution, add the solution to your source control.

How to Use SMO to Create Primary Key

All,
I am using Microsoft Management Objects (SMO) to create a database with it's
associated tables.
All works well until I try to define more than one index as a primary key.
See code below:
// Add two primary key indices
Index pkIndex = new Index(myTable, "PK_MyTable");
pkIndex.IndexKeyType = IndexKeyType.DriPrimaryKey;
pkIndex.IndexedColumns.Add(new IndexedColumn(pkIndex, "Column1"));
pkIndex.IndexedColumns.Add(new IndexedColumn(pkIndex2, "Column2"));
// Add index to the table
myTable.Indexes.Add(pkIndex);
// Create table in database
myTable.Create(); // Throws exception!
Also tried it this way:
// Add two primary key indices
Index pkIndex = new Index(myTable, "PK_MyTable1");
pkIndex.IndexKeyType = IndexKeyType.DriPrimaryKey;
pkIndex.IndexedColumns.Add(new IndexedColumn(pkIndex, "Column1"));
Index pkIndex2 = new Index(myTable, "PK_MyTable2");
pkIndex2.IndexKeyType = IndexKeyType.DriPrimaryKey;
pkIndex2.IndexedColumns.Add(new IndexedColumn(pkIndex2, "Column2"));
// Add index to the table
myTable.Indexes.Add(pkIndex);
myTable.Indexes.Add(pkIndex2);
// Create table in database
myTable.Create(); // Throws exception!
Does anyone know how to define more than one primary key for a table using
SMO?
Thanks in advance.All,
Disregard this question.
Problem was with a column definition, not with the primary key index creatio
n.
Note that the following code works:
// Add two primary key indices
Index pkIndex = new Index(myTable, "PK_MyTable");
pkIndex.IndexKeyType = IndexKeyType.DriPrimaryKey;
pkIndex.IndexedColumns.Add(new IndexedColumn(pkIndex, "Column1"));
pkIndex.IndexedColumns.Add(new IndexedColumn(pkIndex2, "Column2"));
// Add index to the table
myTable.Indexes.Add(pkIndex);
// Create table in database
myTable.Create();

Wednesday, March 7, 2012

How to use CTRL+SHIFT+INSERT to insert template in Management Stud

Hi,
I am trying to create a simple template in Managament Studio editor that has
"Select * from " and try to invoke it by keyboard short cut so that I don't
have to type this everytime I want to type in "Select * from ". Anyone who
has done this kinda thing?
Thanks for the help!
-Josh
You 'could' go to [Tools], [Options], [Environment], [Keyboard], and add a
'hot-key' combination for that string.
However, it is widely considered outside the scope of 'Best Practices' to
use [SELECT *].
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
"Kodi" <Kodi@.discussions.microsoft.com> wrote in message
news:30E4B93A-C842-4D03-BF18-B6C5317C8809@.microsoft.com...
> Hi,
> I am trying to create a simple template in Managament Studio editor that
> has
> "Select * from " and try to invoke it by keyboard short cut so that I
> don't
> have to type this everytime I want to type in "Select * from ". Anyone who
> has done this kinda thing?
> Thanks for the help!
> -Josh

How to use CTRL+SHIFT+INSERT to insert template in Management Stud

Hi,
I am trying to create a simple template in Managament Studio editor that has
"Select * from " and try to invoke it by keyboard short cut so that I don't
have to type this everytime I want to type in "Select * from ". Anyone who
has done this kinda thing?
Thanks for the help!
-Josh
Hi
Having SELECT * FROM in production code is not recommended therefore the
need to do this would only be in ad-hoc queries or possibly EXIST clauses,
therfore the need to do this may not be as great as you expect, expecially as
it is not saving that much typing.
You can assign keys in management studio to run procedures, but not to
insert text. What you may want to look at is the ability to create SELECT
statements from the object explorer (F8) by right clicking the stored
procedure and using the script option to script a select statement to file,
window or the clipboard. Also if you want to insert object names into a
window the object can be dragged across from the object explorer and the name
will be inserted. If you drag the columns branch of a table across you will
get a list of all columns.
You can also create your own templates (see the template explort CTRL+ALT+T)
if you have more complex code needs (such as a stored procedure with standard
error handling block). Templates can contain substitute values such as
SELECT * FROM <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
John
"Kodi" wrote:

> Hi,
> I am trying to create a simple template in Managament Studio editor that has
> "Select * from " and try to invoke it by keyboard short cut so that I don't
> have to type this everytime I want to type in "Select * from ". Anyone who
> has done this kinda thing?
> Thanks for the help!
> -Josh

How to use CTRL+SHIFT+INSERT to insert template in Management Stud

Hi,
I am trying to create a simple template in Managament Studio editor that has
"Select * from " and try to invoke it by keyboard short cut so that I don't
have to type this everytime I want to type in "Select * from ". Anyone who
has done this kinda thing?
Thanks for the help!
-JoshHi
Having SELECT * FROM in production code is not recommended therefore the
need to do this would only be in ad-hoc queries or possibly EXIST clauses,
therfore the need to do this may not be as great as you expect, expecially a
s
it is not saving that much typing.
You can assign keys in management studio to run procedures, but not to
insert text. What you may want to look at is the ability to create SELECT
statements from the object explorer (F8) by right clicking the stored
procedure and using the script option to script a select statement to file,
window or the clipboard. Also if you want to insert object names into a
window the object can be dragged across from the object explorer and the nam
e
will be inserted. If you drag the columns branch of a table across you will
get a list of all columns.
You can also create your own templates (see the template explort CTRL+ALT+T)
if you have more complex code needs (such as a stored procedure with standar
d
error handling block). Templates can contain substitute values such as
SELECT * FROM <schema_name, sysname, dbo>.<table_name, sysname, sample_table
>
John
"Kodi" wrote:

> Hi,
> I am trying to create a simple template in Managament Studio editor that h
as
> "Select * from " and try to invoke it by keyboard short cut so that I don'
t
> have to type this everytime I want to type in "Select * from ". Anyone who
> has done this kinda thing?
> Thanks for the help!
> -Josh

Friday, February 24, 2012

How to use CLR Stored Procedures in Reporting Services?

Hi there.

As subject metioned,I got a problem.

I have a CLR Stored Procedures it works fine in Sql Server Management Studio,but when excuting the stored procedure in Reporting Services Query Builder window(Visual Studio Reporting Services Project),I got a error message "The stored procedure <stored_procedure_name> doesn't exist".

so how to resolve this problem?

my env : SQL Server 2005 , Visual Studio 2005

many thanks.

The CLR stored procedure is attached to a specific database. Make sure that you are connecting to the correct database when you initialize the data source you are using. I have gotten CLR stored procedures to work so I know they will work in Reporting Services.|||

Maybe i got something wrong,i'll check it.

Now i use a T-SQL Stored Procedure as a wrapper to call the CLR one,and it works fine.

thanks and best regards :D

|||

Hi,

I have the same problem.

I also tried with the t-sql stored procedure as wrapper, but when executing it, I get the error

"The transaction context is already in use in another session".

This time the error appears executing the stored procedure from Sql Server Management Studio too.

So I'm giving up. Unless somebody has some suggestions.

Bye.

How to use CLR Stored Procedures in Reporting Services?

Hi there.

As subject metioned,I got a problem.

I have a CLR Stored Procedures it works fine in Sql Server Management Studio,but when excuting the stored procedure in Reporting Services Query Builder window(Visual Studio Reporting Services Project),I got a error message "The stored procedure <stored_procedure_name> doesn't exist".

so how to resolve this problem?

my env : SQL Server 2005 , Visual Studio 2005

many thanks.

The CLR stored procedure is attached to a specific database. Make sure that you are connecting to the correct database when you initialize the data source you are using. I have gotten CLR stored procedures to work so I know they will work in Reporting Services.|||

Maybe i got something wrong,i'll check it.

Now i use a T-SQL Stored Procedure as a wrapper to call the CLR one,and it works fine.

thanks and best regards :D

|||

Hi,

I have the same problem.

I also tried with the t-sql stored procedure as wrapper, but when executing it, I get the error

"The transaction context is already in use in another session".

This time the error appears executing the stored procedure from Sql Server Management Studio too.

So I'm giving up. Unless somebody has some suggestions.

Bye.