Advantages Of Stored Procedures?

Aug 3, 2004

Hi,


Generally I write all my SQL in Stored Procedures instead of using adhoc queries. But I dont feel good about stored procedures when I come across situations like this.





Lets say that I have a stored procedure something like this





CREATE PROCEDURE dbo.proc_MYSP


@CaseID char(10)


AS


SELECT * FROM TABLE1WHERE CASEID = @CASEID





Suppose in future if the field CASEID is changed to char(20) then I need to change the declaration of CaseID in all my stored procedures that take CaseID as input parameter. If I write adhoc queries then I need not worry about this. Is there any effective solution for a situation like this.





Thank you.

View 5 Replies


ADVERTISEMENT

Oracle Stored Procedures VERSUS SQL Server Stored Procedures

Jul 23, 2005

I want to know the differences between SQL Server 2000 storedprocedures and oracle stored procedures? Do they have differentsyntax? The concept should be the same that the stored proceduresexecute in the database server with better performance?Please advise good references for Oracle stored procedures also.thanks!!

View 11 Replies View Related

Stored Procedures 2005 Vs Stored Procedures 2000

Sep 30, 2006

Hi,



This Might be a really simple thing, however we have just installed SQL server 2005 on a new server, and are having difficulties with the set up of the Store Procedures. Every time we try to modify an existing stored procedure it attempts to save it as an SQL file, unlike in 2000 where it saved it as part of the database itself.



Thank you in advance for any help on this matter



View 1 Replies View Related

All My Stored Procedures Are Getting Created As System Procedures!

Nov 6, 2007



Using SQL 2005, SP2. All of a sudden, whenever I create any stored procedures in the master database, they get created as system stored procedures. Doesn't matter what I name them, and what they do.

For example, even this simple little guy:

CREATE PROCEDURE BOB

AS

PRINT 'BOB'

GO

Gets created as a system stored procedure.

Any ideas what would cause that and/or how to fix it?

Thanks,
Jason

View 16 Replies View Related

How To Search And List All Stored Procs In My Database. I Can Do This For Tables, But Need To Figure Out How To Do It For Stored Procedures

Apr 29, 2008

How do I search for and print all stored procedure names in a particular database? I can use the following query to search and print out all table names in a database. I just need to figure out how to modify the code below to search for stored procedure names. Can anyone help me out?
 SELECT TABLE_SCHEMA + '.' + TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'

View 1 Replies View Related

Using A Stored Procedure To Query Other Stored Procedures And Then Return The Results

Jun 13, 2007

Seems like I'm stealing all the threads here, : But I need to learn :) I have a StoredProcedure that needs to return values that other StoredProcedures return.Rather than have my DataAccess layer access the DB multiple times, I would like to call One stored Procedure, and have that stored procedure call the others to get the information I need. I think this way would be more efficient than accessing the DB  multiple times. One of my SP is:SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived,     I.Expired, I.ExpireDate, I.Deleted, S.Name AS 'StatusName', S.ItemDetailStatusID,    S.InProgress as 'StatusInProgress', S.Color AS 'StatusColor',T.[Name] AS 'TypeName',    T.Prefix, T.Name AS 'ItemDetailTypeName', T.ItemDetailTypeID    FROM [Item].ItemDetails I    INNER JOIN Item.ItemDetailStatus S ON I.ItemDetailStatusID = S.ItemDetailStatusID    INNER JOIN [Item].ItemDetailTypes T ON I.ItemDetailTypeID = T.ItemDetailTypeID However, I already have StoredProcedures that return the exact same data from the ItemDetailStatus table and ItemDetailTypes table.Would it be better to do it above, and have more code to change when a new column/field is added, or more checks, or do something like:(This is not propper SQL) SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived,     I.Expired, I.ExpireDate, I.Deleted, EXEC [Item].ItemDetailStatusInfo I.ItemDetailStatusID, EXEC [Item].ItemDetailTypeInfo I.ItemDetailTypeID    FROM [Item].ItemDetails IOr something like that... Any thoughts? 

View 3 Replies View Related

How To Save Stored Procedure To NON System Stored Procedures - Or My Database

May 13, 2008

Greetings:

I have MSSQL 2005. On earlier versions of MSSQL saving a stored procedure wasn't a confusing action. However, every time I try to save my completed stored procedure (parsed successfully ) I'm prompted to save it as a query on the hard drive.

How do I cause the 'Save' action to add the new stored procedure to my database's list of stored procedures?

Thanks!

View 5 Replies View Related

What R The Advantages Of SQL 2k Over Sql 7

May 3, 2002

Hi,

I was looking for some information / papers giving the advantages of Sql 2k over sql7.

Thanks!

View 1 Replies View Related

Stored Procedure Being Saved In System Stored Procedures

Apr 7, 2006

We recently upgraded to SQL Server 2005. We had several stored procedures in the master database and, rather than completely rewriting a lot of code, we just recreated these stored procedures in the new master database.

For some reason, some of these stored procedures are getting stored as "System Stored Procedures" rather than just as "Stored Procedures". Queries to sys.Objects and sys.Procedures shows that these procs are being saved with the is_ms_shipped field set to 1, even though they obviously were not shipped with the product.

I can't update the sys.Objects or sys.Procedures views in 2005.

What effect will this flag (is_ms_shipped = 1) have on my stored procedures?

Can I move these out of "System Stored Procedures" and into "Stored Procedures"?

Thanks!

View 24 Replies View Related

How Can I Call One Or More Stored Procedures Into Perticular One Stored Proc ?

Apr 23, 2008

Hello friends......How are you ? I want to ask you all that how can I do the following ?
I want to now that how many ways are there to do this ?



How can I call one or more stored procedures into perticular one Stored Proc ? in MS SQL Server 2000/05.

View 1 Replies View Related

SSIS And Stored Procedures Results Stored In #Tables

Mar 26, 2008

Hello
I'm start to work with SSIS.

We have a lot (many hundreds) of old (SQL Server2000) procedures on SQL 2005.
Most of the Stored Procedures ends with the following commands:


SET @SQLSTRING = 'SELECT * INTO ' + @OutputTableName + ' FROM #RESULTTABLE'

EXEC @RETVAL = sp_executeSQL @SQLSTRING


How can I use SSIS to move the complete #RESULTTABLE to Excel or to a Flat File? (e.g. as a *.csv -File)

I found a way but I think i'ts only a workaround:

1. Write the #Resulttable to DB (changed Prozedure)
2. create data flow task (ole DB Source - Data Conversion - Excel Destination)

Does anyone know a better way to transfer the #RESULTTABLE to Excel or Flat file?

Thanks for an early Answer
Chaepp

View 9 Replies View Related

Advantages Of SQL Server

Apr 20, 2004

hi ! my boss is thinking of redoing our accounting system which is currently running on FOXPRO - we are planning on a VB/SQL SERVER platform.but he isn't convinced that the benefits of SQL server outweigh those offered by FOXPRO especially since everyone in the office is very comfortable with Foxpro.Can anyone give me some solid advantages of SQL SErver or any other RDBMS over Foxpro ?

View 14 Replies View Related

Advantages Of SQL Express

Oct 4, 2006

Hi,

If I have an application that has at most 20 users with an average of 3-4 concurrent requests to the server and the databases size is 1 gig probably to grow to at most 1.5 gigs in the next 5 years why would I choose Express over MSDE?

MSDE can take advantage of more than 1 gig of memory and can use 2 CPUs. I really don't see any benefit whatsoever in my case to go to SQL Express, in fact all I see is drawbacks.

I hear about upgrading all over the place but I just don't see any good reason in my situation. Am I missing something here?

View 7 Replies View Related

SSIS Advantages

Jan 3, 2007

This may be too general a question but I'm going to ask it anyway.

I'm moving data from a source DB (say A) to a target DB (say B). On A I need to join 3 tables and, after some lookups etc., I need to populate several tables in B. Inserting into B's tables involves sequential operations because in many cases I have to get back the value of an Identity column to use as in input value in a another table 'downstream'. Additionally, the tables in B are populated as a group i.e. if the insert on any one fails the entire group's insertion needs to be rolled back.

I set up a set of stored procedures to do this. The master Stored Proc opens a read-only cursor and for each row of the cursor executes the other SPs in proper sequence. Some of the SPs are 'enclosed' within a transaction to enable a Rollback on the group.

My major concern with this approach was the 'known' inefficiency of the cursor and the huge memory requirement it's use would entail (the cursor would pull about 15 million rows).

So I began looking into SSIS thinking it would be able manage the system resources aspect effectively and offer better performance overall. I've realized, however, that even in SSIS I would essentially need to first pull the 14 mil rows into a memory-resident object (or a temp table - whose benefit I'm not convinced of or haven't fully understood) before looping through each row to perform the data inserts into B.

So, is there any real advantage to this over the first approach ? Perhaps I haven't looked deep enough or wide enough. Any constructive suggestions / feedback would be highly appreciated.

Thanks.

View 5 Replies View Related

MS SQL Stored Procedures Inside Another Stored Procedure

Jun 16, 2007

Hi,
 Do you know how to write stored procedures inside another stored procedure in MS SQL.
 
Create procedure spMyProc inputData varchar(50)
AS
 ----- some logical
 
 procedure spMyProc inputInsideData varchar(10)
AS
   --- some logical
  ---  go
-------

View 5 Replies View Related

Calling Stored Procedures From Another Stored Procedure

May 8, 2008

I am writing a set of store procedures (around 30), most of them require the same basic logic to get an ID, I was thinking to add this logic into an stored procedure.

The question is: Would calling an stored procedure from within an stored procedure affect performance? I mean, would it need to create a separate db connection? am I better off copying and pasting the logic into all the store procedures (in terms of performance)?

Thanks in advance

John

View 5 Replies View Related

Advantages Of Database Diagram

Jun 22, 2007

What is the advantages/disadvantages of using Database Diagram and link all the tables in MS SQL Server Management Studio versus letting the application check and link the different tables at run time? Currently, I do not have all my tables linked in a Database Diagram. I do everything at run time in my application code behind. What are the best practices? Which is easier or perhaps more secure?

View 4 Replies View Related

Advantages Of Sql Server 2005

Jun 20, 2008

Hi to all,                Can anybody tell me what are the main advantage's of sql server 2005 ? 

View 1 Replies View Related

Article On Advantages Of Sql Server Over VFP

Oct 9, 2007

hi guys,

im new to sql server...

i am currently studying sql server 2000

i know this subject has been asked before...

i would just like to ask if you know some related articles regarding advantages of using sqlserver over vfp dbf/dbc?

i am going to discuss it to my class.

thanks very much!

any help is very much appreciated!

Joel

View 4 Replies View Related

Advantages And Disadvantages Of The Replication Ty

Feb 13, 2008

hi,
Can any body help me in knowing what are the advantages and disadvantages of all the three replication types?

View 1 Replies View Related

Advantages/Disadvantages To Using More Than One Database

Dec 18, 2006

I have a content site where everything is currently in one SQL ServerDB. As I add features to the site, for example message boards andblogging, does it make sense to put those features in a separatedatabase? What would I lose and gain in doing so? Thanks so much.Erik

View 3 Replies View Related

What Are Advantages Of Using Null Values In SQL?

Mar 11, 2008



Can I get answer of this ? with some of examples if it is possible.

View 2 Replies View Related

Calling A Stored Procedure Inside Another Stored Procedure (or Nested Stored Procedures)

Nov 1, 2007

Hi all - I'm trying to optimized my stored procedures to be a bit easier to maintain, and am sure this is possible, not am very unclear on the syntax to doing this correctly.  For example, I have a simple stored procedure that takes a string as a parameter, and returns its resolved index that corresponds to a record in my database. ie
exec dbo.DeriveStatusID 'Created'
returns an int value as 1
(performed by "SELECT statusID FROM statusList WHERE statusName= 'Created') 
but I also have a second stored procedure that needs to make reference to this procedure first, in order to resolve an id - ie:
exec dbo.AddProduct_Insert 'widget1'
which currently performs:SET @statusID = (SELECT statusID FROM statusList WHERE statusName='Created')INSERT INTO Products (productname, statusID) VALUES (''widget1', @statusID)
I want to simply the insert to perform (in one sproc):
SET @statusID = EXEC deriveStatusID ('Created')INSERT INTO Products (productname, statusID) VALUES (''widget1', @statusID)
This works fine if I call this stored procedure in code first, then pass it to the second stored procedure, but NOT if it is reference in the second stored procedure directly (I end up with an empty value for @statusID in this example).
My actual "Insert" stored procedures are far more complicated, but I am working towards lightening the business logic in my application ( it shouldn't have to pre-vet the data prior to executing a valid insert). 
Hopefully this makes some sense - it doesn't seem right to me that this is impossible, and am fairly sure I'm just missing some simple syntax - can anyone assist?
 

View 1 Replies View Related

Advantages/Disadvantages B/w Being Consultant Vs Employee

Jul 12, 2000

Hi, I would appreicate your opinion/ feed back about Being consultant vs Being employee.

What are the advantages/disadvantages.
Does consultant makes more money than an employee and why so


Thanks for your response
Ali

View 2 Replies View Related

Advantages&&Disadvantages Logical Drives

Aug 5, 2005

Are they're any real disadvantages or advantages in having 1 massive disk partioned to create 2 logical drives (not including the C drive) and separating the SQL Database File & Transaction Log so that it doesnt reside on the same logical drive?

After all, it is still a single disk.

thanks.

View 3 Replies View Related

Multiple Devices For A Database - Advantages?

Nov 6, 1999

Just wondering - on a straight RAID 5 system is there any advantage, performance or otherwise, to splitting a SQL 6.5 database over multiple database devices? Or for simplicity's sake am I just further off creating a single device and manually extending it as the database grows?

Thanks
RM

View 1 Replies View Related

Advantages Of Changing Compatibility Level

Jun 12, 2008

Dear All,
what are the advantages of changing compatibility level from 80 to 90? are there any disadvantages doing this on production machine? will it take any downtime?
i've searched the google but i didnt get the correct info.

Arnav
Even you learn 1%, Learn it with 100% confidence.

View 2 Replies View Related

I Want To Know About Advantages And Disadvantages Of SQL Server 2005.

Nov 23, 2007

Please reply me as soon as possible.

View 4 Replies View Related

Advantages Of Reporting Services 2005

Sep 27, 2007



Hello,

I am working on the Reporting Services 2005, I don' know anything about Business Object.

Please let me know what are the advantages of Reporting Services 2005 over the Business Object.

Any specific link will be useful for me.

Thanks in advance.
Bye.

View 5 Replies View Related

SQL 2012 :: Advantages Over SERVER AlwaysOn Over Clustering

May 14, 2015

Give the Advantages Over SQL SERVER Always on over Clustering....

View 4 Replies View Related

Speed SQLExpressvs Access2003 Via Oledb??? Advantages???

Mar 19, 2008

I am trying to evaluate the pros and cons of using SQL Server over oledb connection to an access database.

So far



Pros Cons
Access: Doesnt need to be installed by user. 2GB Data limit

SQLExpress:
Not sure yet - more than 2gb data User has to install SQL Server compact.

Is there anything iv missed?

Iv run a quick test to decide on speed my results seem to suggest that oledb is faster at writing data, and SQL Server is faster at reading.

The test program clears the database:

and times how long it takes to insert 10000 records, the read the 10000 records back for OLEDB, then SQL Express.




Code Snippet
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Timers;
namespace ConsoleApplication1
{
class Program
{
static int a = 0;
static int b = 0;
static void Main(string[] args)
{

Timer tmr0 = new Timer(1);
Timer tmr1 = new Timer(1);
tmr1.Elapsed += new ElapsedEventHandler(tmr1_Elapsed);
OleDbConnection oledbcon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database1.mdb");
oledbcon.Open();
OleDbCommand oledbcmd = new OleDbCommand("INSERT INTO Table1 (Can) VALUES ('1')",oledbcon);
oledbcmd.CommandText = "DELETE * FROM Table1";
oledbcmd.ExecuteNonQuery();
tmr0.Elapsed += new ElapsedEventHandler(tmr0_Elapsed);
tmr0.Enabled = true;
for (int i = 0; i < 10000; i++)
{
oledbcmd.CommandText = "INSERT INTO Table1 (Can) VALUES ('" + i.ToString() + "')";
oledbcmd.ExecuteNonQuery();
}
int aa = a;
a = 0;

oledbcmd.CommandText = "SELECT * FROM Table1";
OleDbDataReader oledbreader;
oledbreader = oledbcmd.ExecuteReader();
while (oledbreader.Read())
{
oledbreader.GetInt32(0);
}
tmr0.Enabled = false;
SqlConnection sqlcon = new SqlConnection("Data Source=localhost\SQLEXPRESS;Initial Catalog=;Integrated Security = SSPI");
sqlcon.Open();
SqlCommand sqlcmd = new SqlCommand("CREATE DATABASE Test",sqlcon);
try
{
sqlcmd.ExecuteNonQuery();
}
catch { }
sqlcmd.CommandText = "CREATE TABLE Table1 (num INT)";
try { sqlcmd.ExecuteNonQuery(); }
catch { }
sqlcmd.CommandText = "DELETE FROM Table1";
sqlcmd.ExecuteNonQuery();
tmr1.Enabled = true;
for (int i = 0; i < 10000; i++)
{
sqlcmd.CommandText = "INSERT INTO Table1 (num) VALUES ('" + i.ToString() + "')";
sqlcmd.ExecuteNonQuery();
}
int bb = b;
b = 0;
sqlcmd.CommandText = "SELECT * FROM Table1";
SqlDataReader sqlreader = sqlcmd.ExecuteReader();

while (sqlreader.Read())
{
sqlreader.GetInt32(0);
}
tmr1.Enabled = false;
Console.WriteLine("OLEDB");
Console.WriteLine("Inserted 10000 records in "+aa.ToString()+"ms");
Console.WriteLine("Read 10000 records in " + a.ToString() + "ms");
Console.WriteLine("TOTAL: " + ((a + aa).ToString()) + "ms");
Console.WriteLine("SQL SERVER");
Console.WriteLine("Inserted 10000 records in " + bb.ToString() + "ms");
Console.WriteLine("Read 10000 records in " + b.ToString() + "ms");
Console.WriteLine("TOTAL: " + ((b + bb).ToString()) + "ms");
Console.ReadKey();


}
static void tmr1_Elapsed(object sender, ElapsedEventArgs e)
{
b++;
}
static void tmr0_Elapsed(object sender, ElapsedEventArgs e)
{
a++;
}
}
}


For the access database create a access2003 mdb file with a table "Table1" and a colomn of type integer called "Can";

save it as C:database1.mdb

Then compile and run above.

My results wereslow machine)





OLEDB
Inserted 10000 records in 1512ms
Read 10000 records in 6ms
TOTAL: 1518ms
SQL SERVER
Inserted 10000 records in 1853ms
Read 10000 records in 1ms
TOTAL: 1854ms



Does this

View 2 Replies View Related

Olap Mining - Advantages, Disadvantages And Problems

Jan 19, 2007

Dear Sirs and Madams,

it's quite hard to find informations about OLAP mining I think. So I have some questions to you:

What advantages do I have by using Olap Mining instead of "normal" mining (relational databases)?
Is it just faster or are there other advantages?

What are the disadvantages? The data can be overaggregated (no detailled results), can not? Are there other disadvantages?

What problem do I have to face?

Whats going on with empty cells?

Thank you very much in advance and have a nice weekend.

Thorsten

View 1 Replies View Related

Only Functions And Extended Stored Procedures Can Be Executed From Within A Function. Sp_executesql Is A Extended Stored Prod

May 15, 2008

i have created the folowing function but keep geting an error.

Only functions and extended stored procedures can be executed from within a function.

Why am i getting this error!

Create Function myDateAdd
(@buildd nvarchar(4), @avdate as nvarchar(25))
Returns nvarchar(25)
as
Begin
declare @ret nvarchar(25)
declare @sqlval as nvarchar(3000)

set @sqlval = 'select ''@ret'' = max(realday) from (
select top '+ @buildd +' realday from v_caltable where realday >= '''+ @avdate +''' and prod = 1 )a'

execute sp_executesql @sqlval
return @ret
end

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved