Showing posts with label ref. Show all posts
Showing posts with label ref. Show all posts

Wednesday, March 7, 2012

Ref: Re: Question about stored procedure in SQL Server 2005

Hello all!

I have a (simple) question.

(Sorry for some possible wrong menus-name but I have the italian version of SQL Server 2005 and I'm trying to translate them in best way...)

I want to create a new stored procedure for my database.

I click on "Programmability", then right-click on "Stored procedure" and then click on "New stored procedure".

In the Query Analyzer I write the procedure following the correct syntax, check the sp to be sure that is correct and everything is ok.

The problem is that, when I save the sp, I can create a file with extension .sql, but I don't see the new sp created on the list of stored procedure of the database.....

What's wrong?

Thank you in advance for your help!

Bye

nino

Save is just save your script on your disk for future use (re-usable). But it will not update/save in the database.

You have to execute the script to craete the proc (the button with ! or you can press F5)..

|||

Just Execute created script for your New Stored Procedure.

|||

Just to be exact...

the sp is like this:

Code Snippet

use [db_something]

go

[...]

create procedure [dbo].[updateService]

@.idS int,

@.name varchar(20),

@.var1 varchar(10),

@.var2 int

as

update Tservices

set variable1 = @.var1, variable2 = @.var2

where idService= @.idS and nameX = @.name

go

After this I obviously executed the sp and received "query completed without errors"... But no trace of my sp !!

Bye

Nino

|||

hi,

you just have to run the create script by pressing f5 on the management studio

saving will save the scripts into a physical .sql file but not on the database.

be sure you are running the create script on the appropriate database

to do this issue the use <database> prior to the create proc script

Use northwind

create proc sp1

........

you have probably run the scripts against the master database

regards,

joey

|||

After you run the script execute the following...

Code Snippet

sp_helptext updateService

|||

Thank you all guys!

Now my sp is present.

I hope to contribute in the next not with stupid questions but with good answers!

Bye

Nino

Ref. Matrix totals in another Matrix

Hi All,
I realize that there are countless postings on Matrix totals, but I haven't
found a posting that specifically relates to what I'm trying to accomplish.
What I want to do is reference the calculated totals from one matrix in
another matrix. I don't know if this is even possible, but here's the what
I'm aiming for:
DATE Total Dept. 1 Dept. 2 Dept. 3 .....
Jan. 01 8 1 4 3
Jan. 02 10 2 3 5
Jan. 03 11 3 6 2
...
Jan. 31 9 2 2 5
---
MTD 38 8 15 15
Target 45 15 15 15 .....
Prev. Mon.51 14 18 19
Diff. -13 -6 -3 -4
Perc. 74.5% 57% 83% 78.9%
The MTD row is the Month To Date total for the first matrix (calculated
automatically using 'Subtotal'). Below that is the second matrix used to show
statistics. The reason I'm using a second matrix is because the number of
Departments is not a constant, so the bottom matrix needs the same number of
columns as the top matrix. (I'm using the same criteria for the "Columns",
and then just hiding it.)
The problem is, for the calculations in the bottom matrix, I need to know
the individual totals in each MTD cell in the above matrix, not just the
grand total. Is it possible to access those fields from the expression of a
cell in the bottom matrix (I.E. use the MTD total for Dept. 2 to calculate
the difference between the current month and the previous month in the lower
matrix)?
If not, then that leads me to believe I have the wrong approach to this
problem, and if that's the case, then how else would this be achieved?
Thanks very much in advance.
Martin McCarthyHas anybody come across a situation like this before? Any input would be
appreciated.
Thanks,
Martin
"Joseph Rea, Accord Software" wrote:
> Hi All,
> I realize that there are countless postings on Matrix totals, but I haven't
> found a posting that specifically relates to what I'm trying to accomplish.
> What I want to do is reference the calculated totals from one matrix in
> another matrix. I don't know if this is even possible, but here's the what
> I'm aiming for:
> DATE Total Dept. 1 Dept. 2 Dept. 3 .....
> Jan. 01 8 1 4 3
> Jan. 02 10 2 3 5
> Jan. 03 11 3 6 2
> ...
> Jan. 31 9 2 2 5
> ---
> MTD 38 8 15 15
>
> Target 45 15 15 15 .....
> Prev. Mon.51 14 18 19
> Diff. -13 -6 -3 -4
> Perc. 74.5% 57% 83% 78.9%
>
> The MTD row is the Month To Date total for the first matrix (calculated
> automatically using 'Subtotal'). Below that is the second matrix used to show
> statistics. The reason I'm using a second matrix is because the number of
> Departments is not a constant, so the bottom matrix needs the same number of
> columns as the top matrix. (I'm using the same criteria for the "Columns",
> and then just hiding it.)
> The problem is, for the calculations in the bottom matrix, I need to know
> the individual totals in each MTD cell in the above matrix, not just the
> grand total. Is it possible to access those fields from the expression of a
> cell in the bottom matrix (I.E. use the MTD total for Dept. 2 to calculate
> the difference between the current month and the previous month in the lower
> matrix)?
> If not, then that leads me to believe I have the wrong approach to this
> problem, and if that's the case, then how else would this be achieved?
>
> Thanks very much in advance.
> Martin McCarthy

ref mail error

when I attepmt to start SQL ServerAgent I get the
following error messages:
[298] SQLServer Error: 18456, Login failed for user 'sa'.
[SQLSTATE 28000]
[000] Unable to connect to server '(local)';
SQLServerAgent cannot start
In SQL ServerAgent properties my sa password is correct
and I get a similar error message when I select 'Use
Windows authentication' on the Server Conection tab, can
this be caused by a problem with my Service Startup
acount ?
> when I attepmt to start SQL ServerAgent I get the
> following error messages:
> [298] SQLServer Error: 18456, Login failed for user 'sa'.
> [SQLSTATE 28000]
> [000] Unable to connect to server '(local)';
> SQLServerAgent cannot start
> In SQL ServerAgent properties my sa password is correct
> and I get a similar error message when I select 'Use
> Windows authentication' on the Server Conection tab, can
> this be caused by a problem with my Service Startup
> acount ?
The Builtin\Administrators might have been removed as a sysadmin.
Hope this helps,
Eric Crdenas
SQL Server senior support professional

ref mail error

when I attepmt to start SQL ServerAgent I get the
following error messages:
[298] SQLServer Error: 18456, Login failed for user 'sa'.
[SQLSTATE 28000]
[000] Unable to connect to server '(local)';
SQLServerAgent cannot start
In SQL ServerAgent properties my sa password is correct
and I get a similar error message when I select 'Use
Windows authentication' on the Server Conection tab, can
this be caused by a problem with my Service Startup
acount ?> when I attepmt to start SQL ServerAgent I get the
> following error messages:
> [298] SQLServer Error: 18456, Login failed for user 'sa'.
> [SQLSTATE 28000]
> [000] Unable to connect to server '(local)';
> SQLServerAgent cannot start
> In SQL ServerAgent properties my sa password is correct
> and I get a similar error message when I select 'Use
> Windows authentication' on the Server Conection tab, can
> this be caused by a problem with my Service Startup
> acount ?
--
The Builtin\Administrators might have been removed as a sysadmin.
Hope this helps,
Eric Crdenas
SQL Server senior support professional

ref mail error

when I attepmt to start SQL ServerAgent I get the
following error messages:
[298] SQLServer Error: 18456, Login failed for user 'sa'.
[SQLSTATE 28000]
[000] Unable to connect to server '(local)';
SQLServerAgent cannot start
In SQL ServerAgent properties my sa password is correct
and I get a similar error message when I select 'Use
Windows authentication' on the Server Conection tab, can
this be caused by a problem with my Service Startup
acount ?> when I attepmt to start SQL ServerAgent I get the
> following error messages:
> [298] SQLServer Error: 18456, Login failed for user 'sa'.
> [SQLSTATE 28000]
> [000] Unable to connect to server '(local)';
> SQLServerAgent cannot start
> In SQL ServerAgent properties my sa password is correct
> and I get a similar error message when I select 'Use
> Windows authentication' on the Server Conection tab, can
> this be caused by a problem with my Service Startup
> acount ?
--
The Builtin\Administrators might have been removed as a sysadmin.
Hope this helps,
--
Eric Cárdenas
SQL Server senior support professional

ref int between tables in 2 DBs

Hi... this is a multi-part question on the topic of setting up referential
integrity between two tables, one on each separate DB, on the same server.
First, is this even possible? If yes, then how would the foreing key be
referenced? And what if the referential integrity were to expand between two
tables, on separate servers? What implications should one be aware of in
doing so, provided this feature is supported?
Your comments and suggestions are highly appreciated. Thanks in advance.
Regards...examnotes <Rob@.discussions.microsoft.com> wrote in
news:B9763B6E-1408-4D3C-9889-CD1524234F81@.microsoft.com:

> Hi... this is a multi-part question on the topic of setting up
> referential integrity between two tables, one on each separate DB, on
> the same server.
> First, is this even possible? If yes, then how would the foreing key
> be referenced? And what if the referential integrity were to expand
> between two tables, on separate servers? What implications should one
> be aware of in doing so, provided this feature is supported?
Does not appear so:
Msg 1763, Level 16, State 0, Line 1
Cross-database foreign key references are not supported. Foreign key
'AdventureWorks.HumanResources.Employee'.

> Your comments and suggestions are highly appreciated. Thanks in
> advance.
The easiest way of implementing cross-database fk is most likely to use
triggers.
Ole Kristian Bangs
MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging