How to view the procedures in Netezza?
In oracle , we can view with the help of below query.
select * from user_source where object_name=upper('PROC_NAME');
The Netezza equivalent would be:
SELECT * FROM _v_procedure WHERE procedure = 'PROC_NAME';
On the left panel where the databases are shown click the database, click stored procedures, right click on the procedure, click edit procedure and the procedure will be seen on the right panel
Simple way to view procedure signature is -
DB.SCHEMA(USER)=> show procedure <procedure name>
Related
How do I find the query of a stored procedure? Is there any way to view it?
If you are using SQL Server Management Studio, under the database tree, choose Programmability | Stored Procedures. Just right click on the procedure name and click modify.
But the database role will also affect your action.
There are many ways to do this one simple way is
sp_helptext 'Your_SP_Name'
or
SELECT OBJECT_DEFINITION(OBJECT_ID('Your_SP_Name'))
SELECT OBJECT_NAME(id)
FROM syscomments
WHERE [text] LIKE '%%'
AND OBJECTPROPERTY(id, 'IsProcedure') = 1
GROUP BY OBJECT_NAME(id)
Try This Its Worked...
I added a new column to a view in Microsoft SQL Server Management Studio. The data area for the modified view displayed the new column. However when I tried to run a query (e.g. SELECT * FROM uvMyNewView) against that view, it wouldn't display the new column.
I found the solution on the mssqltips website.
exec sp_refreshview [uvMyNewView]
go
select * from [uvMyNewView]
go
Sometimes metadata of view is not updated when we add a column to a table and in view, we use Select * From tablename.
In that condition, we have 2 options either we need to
Alter the view script
exec sp_refreshview 'ViewName' Statment to update the MetaData.
I have procedure dbo.GetData:
Create procedure dbo.GetData
As
Begin
Select * from dbo.tblName
End
And I also created a schema [ABC], table ABC.tblName
So, I would like to change schema [dbo] of table in procedure dbo.GetData into [ABC] by using another stored procedure.
And, the result is:
Create procedure dbo.GetData
As
Begin
Select * from [ABC].tblName
End
How can I do it?
Thank you everyone.
I'm not sure I understand what you're asking, but I think you simply want to change the code being executed in the stored procedure. If so, a simple ALTER PROCEDURE would do the trick to change the code, but not the name:
ALTER PROCEDURE dbo.GetData
AS
BEGIN
SELECT * FROM [ABC].tblName
END
Full syntax of [ALTER PROCEDURE] 1 (for SQL Server)
If this is not what you're after, please clarify the question.
Update:
The only real solution I see is that you script out your procs, and then use a text-editor to replace the dbo. values with [ABC]. values.
I just attempted to try and do this through updating the system tables, but in SQL Server 2012 (which I use), it simply gets far too complex for that.
Try this hope this may help you!
ALTER SCHEMA NewSchemaName TRANSFER OldSchemaName.ObjectName
I want to view my logon trigger and alter it, but I cannot seem to find it. When I create a stored procedure, I can always find the procedure in Database->Programability->Stored Procedures, right click the name of my procedure and click modify. However, when I go to Server Objects->Triggers and I right click on my trigger, there isn't an option for modifying it. What am I supposed to do to modify it?
Thank you.
Right click > Script Server Trigger As > DROP and Create To > New Query Editor Window
So, not sure what is happening. But I have stored procedure and it keeps disappearing out of my DB in SQL 2k.
I can add it again and then try to execute it from my web app and i get an exception saying the stored procedure cant be found. So then ill go back to management and refresh and its gone again !?!
here is the config for the stored proc:
set ANSI_NULLS OFF
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[USP_Equipment_Delete]
#EquipmentID int
AS
DELETE FROM [dbo].[Equipment]
WHERE
[EquipmentID] = #EquipmentID
None of my other stored procedure disappear. This is the only one. I have easily 100 in there. They all use the same SQLHelper class. This one just keeps disappearing!!!??!!
Any help or suggestions are appreciated!
Thanks so much!
You were creating this or another stored proc and at the end of your code, maybe after a comment, where you did not see it you have a drop of this proc.
Take a look at your db using:
select syo.name
from syscomments syc
join sysobjects syo on
syo.id = syc.id
where syc.[text] like '%DROP PROC%'
I had the same problem and I just fixed it:
In the script file it was missing the "GO" statement between the end of the stored procedure and the beginning of the next "IF EXIST THEN DROP" statement.
So what happened was that the drop statement was getting appended to the end of whatever stored procedure was above it in the script. So when the software ran the stored procedure it would drop whatever stored procedure was below it in the script.
It seems so obvious to us now but didn't make any sense at the time. We found it running the SQL profiler against a customer's database that was having the problem in the field.
Are you using the correct database?
Try
using [database name]
prior to executing your stored procedure, just to make sure.
Do you have a CREATE PROCEDURE anywhere? You can't ALTER a procedure if it doesn't exist.
Perhaps the code to access the stored procedure is using a different context other than dbo. Make sure to add dbo.USP_Equipment_Delete to the code using it.
I was facing the problem that all Stored Procedures with a create statement disappeared from the database after execution.
The Solution was: The database user should have the rights to drop,create and alter on the database in which the "Stored Procedures" are going to be created.
Perhaps there's a job thats restoring an old backup periodically?
Check if the "Initial Catalog" in your connection string is set to the correct database.
Put the database in single user mode (and make sure you're the single user) and check if the procedure still disappears every hour?
If it's there, then this query must return a record:
SELECT * FROM sysobjects
WHERE id = OBJECT_ID('USP_Equipment_Delete')
AND OBJECTPROPERTY(id, N'IsProcedure') = 1