Stored Procedure Slower Than Script File

Dec 4, 2007

I am trying to modify a stored procedure written by a consultant for our company. I have my changes made in a script file, and the query will run in about a minute. However, after I made the changes to the stored procedure, it is taking over 5 minutes to run. The procedure uses several temporary table variables, and inserts records into those tables. The results are selected from those table variables joined to other tables.

Why would this be?

View 8 Replies


ADVERTISEMENT

Help Cursor Based Stored Procedure Is Getting Slower And Slower!

Jul 20, 2005

I am begginner at best so I hope someone that is better can help.I have a stored procedure that updates a view that I wrote using 2cursors.(Kind of a Inner Loop) I wrote it this way Because I couldn'tdo it using reqular transact SQL.The problem is that this procedure is taking longer and longer to run.Up to 5 hours now! It is anaylizing about 30,000 records. I thinkpartly because we add new records every month.The procedure works like this.The first Cursor stores a unique account and duedate combination fromthe view.It then finds all the accts in the view that have that account duedatecombo and loads them into Cursor 2 this groups them together for datamanipulation. The accounts have to be grouped this way because aaccount can have different due dates and multiple records within eachaccount due date combo and they need to be looked at this way aslittle singular groups.Here is my procedure I hope someone can shead some light on this. Myboss is giving me heck about it. (I think he thinks Girls cant code!)I got this far I hope someone can help me optimize it further.CREATE PROCEDURE dbo.sp_PromiseStatusASBEGINSET NOCOUNT ON/* Global variables */DECLARE @tot_pay moneyDECLARE @rec_upd VARCHAR(1)DECLARE @todays_date varchar(12)DECLARE @mActivityDate2_temp datetimeDECLARE @tot_paydate datetime/* variables for cursor ACT_CUR1*/DECLARE @mAcct_Num1 BIGINTDECLARE @mDueDate1 datetime/* variables for ACT_CUR2 */DECLARE @mAcct_Num2 BIGINTDECLARE @mActivity_Date2 datetimeDECLARE @mPromise_Amt_1 moneyDECLARE @mPromise_Status varchar(3)DECLARE @mCurrent_Due_Amt moneyDECLARE @mDPD intDECLARE @mPromise_Date datetimeSELECT @todays_date =''+CAST(DATEPART(mm,getdate()) AS varchar(2))+'/'+CAST(DATEPART(dd,getdate()) AS varchar(2))+'/'+CAST(DATEPART(yyyy,getdate()) AS varchar(4))+''DECLARE ACT_CUR1 CURSOR FORSELECT DISTINCTA.ACCT_NUM,A.DUE_DATEFROM VWAPPLICABLEPROMISEACTIVITYRECORDS AOPEN ACT_CUR1FETCH NEXT FROM ACT_CUR1 INTO @mAcct_Num1 , @mDueDate1WHILE (@@FETCH_STATUS = 0)BEGINSELECT @rec_upd = 'N 'DECLARE ACT_CUR2 CURSOR FORSELECTB.ACCT_NUM,B.ACTIVITY_DATE,B.PROMISE_AMT_1,B.PROMISE_STATUS,B.CURRENT_DUE_AMT,B.DAYS_DELINQUENT_NUM,B.PROMISE_DATE_1FROM VWAPPLICABLEPROMISEACTIVITYRECORDS B (UPDLOCK)WHERE B.ACCT_NUM = @mAcct_Num1ANDB.DUE_DATE = @mDueDate1ORDER BY B.ACCT_NUM,B.DUE_DATE,B.ACTIVITY_DATE,CASEB.Time_ObtainedWHEN 0 THEN 0ELSE 1END Desc, B.Time_ObtainedOPEN ACT_CUR2FETCH NEXT FROM ACT_CUR2INTO @mAcct_Num2 ,@mActivity_Date2,@mPromise_Amt_1,@mPromise_Status ,@mCurrent_Due_Amt,@mDPD,@mPromise_DateWHILE (@@FETCH_STATUS = 0)BEGIN----CHECK------------------------------------------------------------------------DECLARE @PrintVariable2 VARCHAR (8000)--SELECT @PrintVariable2 = CAST(@MACCT_NUM2 AS VARCHAR)+''+CAST(@MACTIVITY_DATE2 AS VARCHAR)+' '+CAST(@MPROMISE_AMT_1 ASVARCHAR)+' '+CAST(@MPROMISE_STATUS AS VARCHAR)+''+CAST(@mCurrent_Due_Amt AS VARCHAR)+' '+CAST(@mDPD AS VARCHAR)+''+CAST(@mPromise_Date AS VARCHAR)--PRINT @PrintVariable2----ENDCHECK------------------------------------------------------------IF @mDPD >= 30BEGINSELECT @tot_pay = SUM(CONVERT(FLOAT, C.PAY_AMT))FROM vwAplicablePayments CWHERE C.ACCT_NUM = @mAcct_Num2ANDC.ACTIVITY_DATE >= @mActivity_Date2ANDC.ACTIVITY_DATE < @mActivity_Date2 + 15----CHECK------------------------------------------------------------------------DECLARE @PrintVariable3 VARCHAR (8000)--SELECT @PrintVariable3 ='Greater=30 DOLLARS COLLECTED'--PRINT @PrintVariable3----ENDCHECK------------------------------------------------------------ENDELSE IF @mDPD < 30BEGINSELECT @tot_pay = SUM(CONVERT(FLOAT, C.PAY_AMT))FROM vwAplicablePayments CWHERE C.ACCT_NUM = @mAcct_Num2ANDC.ACTIVITY_DATE >= @mActivity_Date2ANDC.ACTIVITY_DATE BETWEEN @mActivity_Date2 AND@mPromise_Date + 5----CHECK----------------------------------------------------------------------DECLARE @PrintVariable4 VARCHAR (8000)--SELECT @PrintVariable4 ='Less 30 DOLLARS COLLECTED'--PRINT @PrintVariable4----END CHECK------------------------------------------------------------END----------------------------------------MY REVISEDLOGIC-------------------------------------------------------IF @rec_upd = 'N'BEGINIF @mDPD >= 30BEGINSELECT @mActivityDate2_temp = @mActivity_Date2 + 15--DECLARE @PrintVariable5 VARCHAR (8000)--SELECT @PrintVariable5 =' GREATER= 30 USING ACTVITY_DATE+15'--PRINT @PrintVariable5ENDELSE IF @mDPD < 30BEGINSELECT @mActivityDate2_temp = @mPromise_Date + 5--DECLARE @PrintVariable6 VARCHAR (8000)--SELECT @PrintVariable6 =' LESS 30 USING PROMISE_DATE+5'--PRINT @PrintVariable6ENDIF @tot_pay >= 0.9 * @mCurrent_Due_Amt--used to be promise amtBEGINUPDATE VWAPPLICABLEPROMISEACTIVITYRECORDSSET PROMISE_STATUS = 'PK',TOTAL_DOLLARS_COLL = @tot_payWHERE CURRENT OF ACT_CUR2--This statement updates the time that the status was placedinto PK.IF @mPromise_Status IN ('PTP','OP')BEGINUPDATE VWAPPLICABLEPROMISEACTIVITYRECORDSSET Status_Date = @todays_dateWHERE CURRENT OF ACT_CUR2ENDSELECT @rec_upd = 'Y 'ENDIF ((@tot_pay < 0.9 * @mCurrent_Due_Amt) OR @tot_pay IS NULL)AND( @mActivityDate2_temp > @todays_date )--need to put 1dayof month here for snapshot9/01/2004BEGINUPDATE VWAPPLICABLEPROMISEACTIVITYRECORDSSETPROMISE_STATUS = 'OP'WHERE CURRENT OF ACT_CUR2--This statement updates the time that the status was placedinto OP which is the original Activity Date.--The record will hold this date until it goes into PK,PB,orIP.IF @mPromise_Status IN ('PTP','OP')BEGINUPDATE VWAPPLICABLEPROMISEACTIVITYRECORDSSET Status_Date = @mActivity_Date2WHERE CURRENT OF ACT_CUR2ENDENDELSE IF ((@tot_pay < 0.9 * @mCurrent_Due_Amt) OR @tot_pay ISNULL)AND( @mActivityDate2_temp <= @todays_date )--need to put 1dayof month here for snapshot 9/01/2004BEGINUPDATE VWAPPLICABLEPROMISEACTIVITYRECORDSSETPROMISE_STATUS = 'PB',TOTAL_DOLLARS_COLL = case when @tot_pay is nullthen 0 else @tot_pay endWHERE CURRENT OF ACT_CUR2--This statement updates the time that the status was placedinto PB.IF @mPromise_Status IN ('PTP','OP')BEGINUPDATE VWAPPLICABLEPROMISEACTIVITYRECORDSSET Status_Date = @todays_dateWHERE CURRENT OF ACT_CUR2ENDENDENDELSE IF @rec_upd = 'Y'BEGINUPDATE VWAPPLICABLEPROMISEACTIVITYRECORDSSETPROMISE_STATUS = 'IP',TOTAL_DOLLARS_COLL = 0WHERE CURRENT OF ACT_CUR2--This statement updates the time that the status was placedinto IP.IF @mPromise_Status NOT IN ('IP')BEGINUPDATE VWAPPLICABLEPROMISEACTIVITYRECORDSSET Status_Date = @todays_dateWHERE CURRENT OF ACT_CUR2ENDENDFETCH NEXT FROM ACT_CUR2 INTO @mAcct_Num2,@mActivity_Date2,@mPromise_Amt_1,@mPromise_Status ,@mCurrent_Due_Amt,@mDPD,@mPromise_DateENDCLOSE ACT_CUR2DEALLOCATE ACT_CUR2FETCH NEXT FROM ACT_CUR1 INTO @mAcct_Num1 , @mDueDate1ENDCLOSE ACT_CUR1DEALLOCATE ACT_CUR1SET NOCOUNT OFFENDGO

View 15 Replies View Related

Why Is This Stored Procedure Slower Than Dynamic SQL?

Oct 24, 2007



We have a procedure that does some complicated table joins to populate a temporary table (declared in the proc) and then extraneous rows are removed from the table and the remaining rows are returned.

On the production server the procedure takes 22 seconds, but the identical query in a dynamic session window of SQL Server Management Studio takes 2 seconds. That doesn't make any sense.

We've profiled the procedure and discovered that the small loop at the end of the query runs through twice with each iteration taking 10 seconds. Again - the same section (but dynamic) profiles in at 0 seconds. We further narrowed it down to the compound delete statement from the @tblResults table.

Here's the looped section of code:


-- now delete the entries with no content

declare @deleted int

set @deleted = 1

declare @tmp table ([Id] int)

while @deleted <> 0

begin


delete from @tmp

-- get all entries with no child nodes

insert into @tmp ([Id])


select distinct r.[id] from @tblResults r

where r.[id] not in

(

select [Id] from @tblResults

where [Id] in (select distinct ParentId from @tblResults)

)


-- delete entries with no documents and region match
-- (this is where the slowdown occurs)

delete from @tblResults

where [id] in

(


select t.[id] from @tmp t where t.[id] not in


(select distinct dm.metatagid from documentmetatag dm

where dm.documentid in


(select distinct dr.documentid from documentregion dr, @region r

where (dr.regionid = r.regionId or @regionIds is null)

)

)

)


select @deleted = @@rowcount

end




We then return all rows from the @tblResults table.

We are totally stumped on why the procedure would take so much longer than running the same query in a SQL Manager window. Is there some issue with temporary tables as variables in a procedure? Any ideas anyone?

Thanks,
John

View 5 Replies View Related

Same Procedure With Different Name Run Much Slower

Jan 14, 2008

I copied a code from one proc and created new proc with the same code but different name. Using the same parameter for both procedures I got the different time of execution. New one is 4 times slower. I went through execution plan and could not find any changes. Does anyone have any experiance like this?

View 2 Replies View Related

Export Stored Procedure To Flat File And Add Aggregate To End Of The Text File?

Jan 31, 2008

What is the easiest way to accomplish this task with SSIS?

Basically I have a stored procedure that unions multiple queries between databases. I need to be able to export this to a text file on a daily basis and add a total records: row to the end of the text file.

Thanks in advance for any help.

View 7 Replies View Related

Why SSIS Package Slower And Slower

Mar 1, 2008

hi, friends, please look at this:

I have a SSIS package, and inside it I do something like below:

1. I have a SQL component, to give back a object to store the records.
2. I have a VB script component, I direct the object I got in 1 step into the script as a dataset.


My problem is:
I run the package in the SQL SERVER 2005 Store Procedue like this:

do
dtexec.exe package.dtsx
loop untill i>t

I control the it runs 30 times. But I found that the speed is slower and slower.
the first time, it takes about 600 s, but the last time, it takes the 1800 s.

Why?
The package don't drop the object it create during the loop in the Store Procedue ?
Thanks!

View 11 Replies View Related

Report Render In VS2005 Slower Than Stored Proc

Aug 10, 2007

I have searched many forums and found some cases of people also reporting slower rendering in RS than in Management Studio / Query Analyzer. However, none of the other solution suggestions seem to make a difference for me.

I'm a VS/VB developer and have got multiple reports built -- all using stored procedures on the backend -- that all take many times longer to run than if executed via Management Studio (SSMS). My simplest proc takes a couple of parameters (no defaults included) and does a simple select against one table with a few joins. Nothing complicated. It runs in 8 secs for 6867 rows via SSMS. Through RS (running locally through Visual Studio 2005 at this point) it takes around 25-28 secs. Yet, when I'm in the report on the DATA tab (not the PREVIEW tab) the run takes the expected 8 secs ?!?!

All reports are behaving this way.

I am not using cursors.
I have no default values on parameters.
I have added the "WITH RECOMPILE" to the proc statement.
I have "SET NOCOUNT ON" as the first line of the proc.
I hate to say this, but I even connected the proc to Crystal Reports to see how it behaved. It ran in the expected 8 secs.

I've seen some mention by someone that perhaps this is a known issue of RS that it reads the proc twice. Any truth to this?

Also a couple posts have traced and demonstrated that the report is generating significantly more data "reads" via RS than through SSMS.

We're a shop that is considering a switch from Crystal to RS, but we do everything through stored procedures. I need to clear up this issue before I can go forward recommending a switch. I'm including a copy of a typical proc below for review... What am I missing? What's the deal here with RS?



IF OBJECT_ID('dbo.rpt_InactiveAccounts') IS NOT NULL

DROP PROCEDURE dbo.rpt_InactiveAccounts

GO


CREATE PROCEDURE dbo.rpt_InactiveAccounts

(@pRunDate datetime

,@pSalesperson varchar(5000)

,@pIncludeOpen char(1)

)

WITH RECOMPILE

AS


SET NOCOUNT ON

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED



-- CREATE/SETUP TEMP TABLE FOR USE IN PARSING MULTI-VALUED STRING INPUTS

DECLARE @NumberPivot TABLE (NumberID INT PRIMARY KEY)

DECLARE @intLoopCounter INT

SELECT @intLoopCounter =0

WHILE @intLoopCounter <=4999 BEGIN

INSERT INTO @NumberPivot

VALUES (@intLoopCounter)

SELECT @intLoopCounter = @intLoopCounter +1

END



-- CREATE TEMP TABLES TO HOLD PARSED VALUES FROM MULTI-VALUE STRING INPUT PARAMETERS

DECLARE @SalespersonTable TABLE

(tmpSalesperson varchar(30))



-- PARSE OUT @pSALESPERSON PARAMETER AND STORE VALUES IN TEMP TABLE

INSERT INTO @SalespersonTable

SELECT SUBSTRING(',' + @pSalesperson + ',', NumberID + 1,

CHARINDEX(',', ',' + @pSalesperson + ',', NumberID + 1) - NumberID -1)

FROM @NumberPivot

WHERE NumberID <= LEN(',' + @pSalesperson + ',') - 1

AND SUBSTRING(',' + @pSalesperson + ',', NumberID, 1) = ','



SELECT DISTINCT

CASE

WHEN s.Name IS NULL THEN '<< OPEN >>'

ELSE s.Name

END As SalespersonName

,c.ClassId

,c.CustId

,c.Name

,c.Addr1

,c.Addr2

,c.Addr3

,c.City

,State

,CASE

WHEN Len(c.Zip) = 9 And CharIndex(' ', c.Zip, 0) = 0 THEN Left(c.Zip, 5) + '-' + Right(c.Zip, 4)

ELSE c.Zip

END As Zip

,ac1.descr As Terms

,ac2.descr As Status

FROM

ACTCustomer c (NOLOCK)

LEFT OUTER JOIN CustSales cs ON c.CustId = cs.CustId

LEFT OUTER JOIN ACTSalesperson s ON cs.SlsId = s.SalesId

INNER JOIN @SalespersonTable st ON s.Name = st.tmpSalesperson OR (s.Name IS NULL AND @pIncludeOpen = 'Y')

INNER JOIN ACTCode ac1 ON ac1.Code = c.Terms And ac1.FieldId = 'CustTerms'

INNER JOIN ACTCode ac2 ON ac2.Code = c.Status And ac2.FieldId = 'Status'

WHERE

c.LastInvcDate <= @pRunDate

And c.ClassId <> 'TR'

ORDER BY

SalespersonName, Name, CustId

View 1 Replies View Related

Stored Procedure That Uses File On Server

Oct 13, 2006

I have defined an email as a .html file on my server: /Emails/email.htmlThis file defines what the email will look like and in the text I have placed tags that need to be replaced with values.A tag that requires replacement looks like: <#SENDERNAME> or <#RECEIVERNAME>I want to replace these tags with the names of the sender and the receiver respectively.AFTER this is done the email needs to be sent to the receiver's address, let's say: receiver@yes.comI want to create a stored procedure that takes as input the sender and receivername AND receiveraddress.It then uses the file I have defined on my server, replaces the tags and sends the email.How can I do this?!

View 1 Replies View Related

Creating A Stored Procedure From A File

Mar 23, 2008

Is there a way I can use one SQL server 2005 (full edition not express) Stored procedure that can execute a .SQL file as if it were in the SQL management studio Query window?
 I have the situation where I have some .SQL file which were created with the 'Create to File' option in SQL Management studio.  I then want to send them to a user who can execute them to create a SP on his SQL server without having to run the SQL management tools.
 Regards
Clive

View 8 Replies View Related

Cannot Open .fmt File Using A Stored Procedure

Apr 3, 2008

Hi..
  I have a website in which the user uploads a  text file to the webserver. and then i am calling a stored procedure which loads the data into the staging database using bulk copy. since my sql database and the web server are in different machines but on the same domain.. i am accessing the .txt file from the stored procedure by giving http://Ipaddress/ApplicationName/Directory/plan.txt
and the format file using the same address i.e http://Ipaddress/ApplicationName/Directory/plan.fmt
 
But when i press ctrl + click on the text file it take me to that location but when i do the same for the format file it says the page cannot be found.. Since it cannot access the .fmt file my import doesnt work.
Any help will be appreicated..
Thank you,
Karen

View 4 Replies View Related

How Can I Execute A N Exe File From Stored Procedure?

Aug 24, 2004

hi to all,

i have a stored procedure and i want to run a program from it..
i think that i need use api functions but how can i do that..
if there is a nother ways please tell me..

thanx..

View 3 Replies View Related

How To Pass Xml File To A Stored Procedure

Nov 30, 2005

hi,i am passing a xml file name to the stored procedure.   the SP  parses the file. but it is giving the error' INVALID AT THE TOP LEVEL OF THE DOCUMENT 'I expect this because of + and - in the xml file bafore the parent tags.how can i do the parser to eliminate these.

View 1 Replies View Related

Excel File & Stored Procedure

Aug 5, 2002

Anyone have the code used in DTS to make a connection to Excel? Or perhaps a better idea? I need to pass different file names to a stored procedure which would upload the spreadsheet data into SQL7 on demand.

View 1 Replies View Related

How To Print To A File Using T-SQL Or Stored Procedure

Sep 7, 2000

Does anyone know how to print to a file or printer using T-SQL or stored procedure?

Thanks

View 1 Replies View Related

&#34;Help&#34; File For User Stored Procedure

Mar 18, 2002

I've been administering SQL Server for quite a while, but have managed until now to stay out of the development side. I find myself finally writing some complex SProcs. What I want to do is to create a "switch", i.e., a parameter that will output a few lines of text characterizing the SProc, with such information as required & optional parameters, potential "gotchas", and a handful of examples of usage. I want this to be able to work like this:

EXEC spMySProc '?'
or
EXEC spMySproc 'help'

This has to work even if there are multiple required parameters.

Thanks for your help!

View 1 Replies View Related

Exporting A Csv File Via A Stored Procedure

Jun 16, 2008

Reading through the forums, I found some great imformation for importing/exporting an excel spreadsheet via a stored procedure, however, the amount of data I have won't fit in excel. Can someone help me export a CSV file via a stored procedure? I don't know if XML is the answer or if there is another way. I am able to use Bulk for an insert of a csv via stored procudure, although it doesn't allow me to use a variable for the file name and pass it in. We are currently using SQL Server 2000.

Thank you,
Stacy

View 1 Replies View Related

How To Make BAT File Of Stored Procedure

Mar 29, 2013

I have a bulk insert script. I have a stored procedure. I saved the stored procedure as a .sql file in another folder too. I have another program that can "run external program" and the only files it will run is a .bat or .exe. I want my other program to be able to trigger the stored procedure to run. I think this means I need a .bat file.

Here is my stored procedure:

USE [EricaTraining]
GO
/****** Object: StoredProcedure [dbo].[LoadDailyAdjReport] Script Date: 03/29/2013 10:56:42 ******/
SET ANSI_NULLS ON
GO

[code]....

View 10 Replies View Related

How To Create A Dbf File From A Stored Procedure?

Jan 28, 2008

Hi there,

Does anyone know any possible way of creating a dbf file from within a stored procedure?

Any guidence, articles, examples, topics to revice would be a great help.

Thanks guys
Butterfly82

View 6 Replies View Related

Use Function From Asp File In Stored Procedure

Jul 23, 2005

Hello everybody,I have a file with several asp functions where some depend on others.Some of the functions I will need to transform a string value.How can I include these functions in a stored procedure? (in SqlServer 2000)Do I have to add all the functions as userdefined functions?Or is possible to reference the external file like include files inasp?Thank you for your help!Regards,Michael

View 3 Replies View Related

Generate XML File From Stored Procedure

Jul 20, 2005

I need to develop some crystal reports on some .NET ado datasets.This is easy to do if I actually had data to work with. It is mucheaser creating reports with you have data.Therefore, I would like to run the stored procedure that the .NET adodataset is built on and generate an XML file. I could run the projectand try to figure out where the developers are making the call to thestored procedure and insert a line to writetoxmlfile. I would rathernot have to mess with their code.Is there a way working with SQL Server (either query analyzer orenterprise manager, dts, or whatever) that I can generate an xml file.I see that I can run a stored procedure and get an xml style return inquery analyzer, but I don't know how to save that as an actual file.Thanks for the help.Tony

View 3 Replies View Related

Copy File In Stored Procedure

Jul 19, 2006

All I want to do is copy a text file and add a 1 after the name in a stored procedure that already cretes this file.



CREATE PROCEDURE [dbo].[sp_export_req] AS
DECLARE @trenutniRed varchar(30),
@tableRow1 varchar(3000),
@sql varchar(4000),
@sql1 varchar(4000),
@firstColumnName varchar(30),
@HTMLfile varchar(1000),
@columnNumber varchar(30),
@fs int,
@ole int,
@file int
declare @body as nvarchar(225)
CREATE TABLE #temptableHTML (code nvarchar(225))
select @HTMLfile = 'c: est_new.txt'

This is the start of the procedure that creates the test_new.txt file. I want to copy the test_new.txt file and name it test_new1.txt. Any help is appreciated. thank you

View 1 Replies View Related

Cannot Open .fmt File Using A Stored Procedure

Apr 3, 2008



Hi..

I have a website in which the user uploads a text file to the webserver. and then i am calling a stored procedure which loads the data into the staging database using bulk copy. since my sql database and the web server are in different machines but on the same domain.. i am accessing the .txt file from the stored procedure by giving http://Ipaddress/ApplicationName/Directory/plan.txt

and the format file using the same address i.e http://Ipaddress/ApplicationName/Directory/plan.fmt



But when i press ctrl + click on the text file it take me to that location but when i do the same for the format file it says the page cannot be found.. Since it cannot access the .fmt file my import doesnt work.

Any help will be appreicated..

Thank you,

Karen

View 5 Replies View Related

Logging Stored Procedure Changes Into File

Jul 25, 2007

Hello all,

I have a big stored procedure which is going to alter many tables,insert data, basically lot of changes.

So, i want to have a text file (or) any log file which will display, what all the changes does the stored procedure has done ( They dont want profiler output )

Can anybody know how to log the results of execution of stored procedure to a text file.

Thanks.

View 2 Replies View Related

How Do I Create Common Stored Procedure From Xsd File ?

Apr 26, 2007

In XSD file keep specification of each tables
So I think It would have some class or method to generate common stored procedure from xsd file.
 
Please help me.

View 1 Replies View Related

How Can I Include A Timestamp On A File Name In A Stored Procedure???

Oct 24, 2007

ok...i give up.....
can this be done? (sql server 2000)
all i want to do is have my stored procedure output some data to a file and i want the filename to include a time stamp.
here's my current working file output code:
EXEC master..xp_cmdshell 'bcp "select * from CEData..employee" queryout "c:employees.txt" -c -Usa -P'
i'd like it to be something like this:
EXEC master..xp_cmdshell 'bcp "select * from CEData..employee" queryout "c:employees" + datetime + ".txt" -c -Usa -P'
but nothing seems to work.
 

View 16 Replies View Related

How To Pass XML File To Stored Procedure (Urgent)

Dec 18, 2007

i am trying to pass a large XML file from VS2005 (web service layer) to stored procedure (SQL Server 2000)In my stored procedure, the input parameter takes as "nText" (which will be XML file)Question:While performing ExecuteNonQuery, i am getting request timeout i think this is coz of large XML file i am passing.can anyone plz tell me how to pass XML file to SP...it would be better if you can provide me with some codei am completely new to this XML file passing between web service and SP...... thanks a lot in advance..... 

View 7 Replies View Related

Execute Stored Procedure From Code Behind File

Mar 15, 2008

hi all
I have to execute the stored procedure from code file
string constr = ConfigurationSettings.AppSettings["ConnectionString"];SqlConnection con = new SqlConnection(constr);con.Open();SqlCommand cmd = new SqlCommand("GetTax",con);cmd.CommandType = CommandType.StoredProcedure;SqlParameter paramFrom = new SqlParameter("@from", SqlDbType.VarChar, 50);paramFrom.Value = "JFK";SqlParameter paramTo = new SqlParameter("@To", SqlDbType.VarChar,50);paramTo.Value = "HOU";SqlParameter paramAirline = new SqlParameter("@Airline", SqlDbType.VarChar,50);paramAirline.Value = "US";SqlParameter rpTax = new SqlParameter("@Tax",SqlDbType.Int);rpTax.Direction = ParameterDirection.Output;cmd.Parameters.Add(rpTax);
insted of this way can i execute stored procedure any other way
like
exec MystoredProc "param1"."param2","param3"
 i appreciate u r help
 
 
 

View 2 Replies View Related

Stored Procedure That Imports A Text File

Aug 4, 2004

Hi guys,

I need to be able to send a text file with data seperated by tabs to a stored procedure that populates my table.

I am new to SQL and SPROCs that I am not sure how to even start. If you guys have any ideas I would really like to hear them or maybe any on-line docs and examples.


Thanks in advance!

View 2 Replies View Related

How To Pass Xml File Name As Parameter To Stored Procedure

Nov 30, 2005

hi,i have created a stored procedure to read xml dataCREATE PROCEDURE InsertXML(@xml varchar(1000)) AS DECLARE @XmlHandle intEXEC sp_xml_preparedocument @XmlHandle output,@xmlinsert into Employee(Name,ID,Sal,Address) (SELECT Name,ID,Sal,AddressFROM  OPENXML (@XmlHandle, 'emp:EmployeeDetails/emp:Employee',2)             WITH (Name varchar(30) 'Name',                       ID int 'ID',                       Sal int 'sal',        Address varchar(30) 'Address'))EXECUTE sp_xml_removedocument @XmlHandlebut it is taking only xml text as input.but i want to send the file name as input.how to do it.

View 2 Replies View Related

Stored Procedure Output To Text File

Apr 13, 2001

Hi List

I have stored procedure which need 4 input variables. I want to send the stored procedure output to Table or text file. Is there any way I can do it let me know. Here is the stored procedure.

Exec TestProcedure 'USD',@test1 output, @test2 output, @test3 output

Thanks in advance

Wang...

View 2 Replies View Related

Create A Text File From W/in A Stored Procedure

Sep 7, 1999

Is there a way to use BCP or something else within a stored procedure to extract data from a select statement out to a text file?

View 4 Replies View Related

Stored Procedure That Create A Text File

Aug 7, 1998

Hi!!!

Is it possible to create a stored procedure which will create a text file (containing information from some tables) and send it via e-mail to a list of user.

I know that I will have to configure the SQL Mail.

If it is possible, can someone give me sample code.

Thanks you.

View 1 Replies View Related

Read A Flat File From Stored Procedure.

Jun 27, 2001

Hi,

How to read from a flat file in a stored procedure. Is there any built in utility available ? Please let me know.

Mahesh.

View 2 Replies View Related







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