After I change a fairly complex stored procedure and I run a report
against it, crystal hangs at "assesing database". I have verified the
database. When I run a trace on SQL is shows repeated cachemiss over
and over. I let it run for 30 minutes and nothing.
Anyone?
I am not sure if this thread needs to go into this forum or there is one for C# stored procedures/CLR Database Objects.
To All:
Is this a known issue that when debugging CLR stored procedures the VS 2005 freezes even before reaching into the stored procedure? I can restart my computer and debugging works for a while and then it starts to take forever when I step into (F10) during debugging. I am running only one instance of sql server, and even that of my local machine as I have never been able to debug on a remote server.
This random and unstable behavior of the debugger is proving very unproductive and costly. Is there a microsoft update/fix/patch to make debugging CLR stored procedures a smooth process?
I have a package that hangs in the designer after I change the sql statement in a DataReader Source from a 'select' to a 'call stored procedure'. The stored procedure takes 2 date parameters. I use an expression to build the 'call stored proc' statement and the 2 date strings. The data reader source uses an ADO.Net connection manager. The ADO.Net connection manager uses the provider for MySQL (Connector/.Net 5.1) which I installed from MySQL.com (http://dev.mysql.com/downloads/connector/net/5.1.html). Before creating the stored procedure I had been using an expression to build a 'select' statement with two date variables as follows:
The sql for the data reader source is set via the sql command property of the data flow component.
After testing the sql, I created a stored proc from this sql and then changed the expression (using the sql command property of the the data flow component) to build the 'call stored proc' statement, like this.
then when I tried to switch to the data flow tab, the editor froze, with the status bar saying "validating datareader source". The data flow tab says "Loading...". I don't know how to troubleshoot this. Each time I have tried I have had to kill the application. Any ideas/suggestions?
I am trying to move data from a transactional database to a data warehouse using a slowly changing dimension. The transactional data comes from a view in SQL server that takes <60 seconds to run and returns about 60k rows. The warehouse table is currently 80k rows long (and growing), and contains 7 historical (type 2) dimensions. When I execute the package in BIDS the DataFlow Task begins to execute, and shows that between 20k and 30k rows have been pulled from the data source into the SCD Transform in the first hour before it simply stops doing anything. This is not to say execution stops; it continues. There is no error thrown. No warning given. System resources are 98% free. The database is not being hit at all. And yet, I have let the package sit 'still' as it were for over 8 hours, and nothing ever happens.
4/8/2008 9:36 4/8/2008 9:36 PrimeOutput will be called on a component. : 1715 : Union All 4/8/2008 9:36 4/8/2008 9:36 A component has returned from its PrimeOutput call. : 1715 : Union All 4/8/2008 9:36 4/8/2008 9:36 PrimeOutput will be called on a component. : 2912 : Staged Queues 4/8/2008 9:36 4/8/2008 9:36 Rows were provided to a data flow component as input. : : 2970 : DataReader Output : 70 : Slowly Changing Dimension : 81 : Slowly Changing Dimension Input : 9947 4/8/2008 9:37 4/8/2008 9:37 A component has returned from its PrimeOutput call. : 2912 : Staged Queues 4/8/2008 9:37 4/8/2008 9:37 A component has returned from its PrimeOutput call. : 2912 : Staged Queues 4/8/2008 9:59 4/8/2008 9:59 Rows were provided to a data flow component as input. : : 1718 : New Output : 1715 : Union All : 1716 : Union All Input 1 : 3825 4/8/2008 9:59 4/8/2008 9:59 Rows were provided to a data flow component as input. : : 1688 : Historical Attribute Inserts Output : 1682 : Get End Date : 1683 : Derived Column Input : 645 4/8/2008 9:59 4/8/2008 9:59 Rows were provided to a data flow component as input. : : 1702 : Derived Column Output : 1692 : Update End Date : 1697 : OLE DB Command Input : 645 4/8/2008 10:01 4/8/2008 10:01 Rows were provided to a data flow component as input. : : 1759 : OLE DB Command Output : 1715 : Union All : 1758 : Union All Input 2 : 645 4/8/2008 10:01 4/8/2008 10:01 Rows were provided to a data flow component as input. : : 2970 : DataReader Output : 70 : Slowly Changing Dimension : 81 : Slowly Changing Dimension Input : 9947 4/8/2008 10:24 4/8/2008 10:24 Rows were provided to a data flow component as input. : : 1718 : New Output : 1715 : Union All : 1716 : Union All Input 1 : 3859 4/8/2008 10:24 4/8/2008 10:24 Rows were provided to a data flow component as input. : : 1688 : Historical Attribute Inserts Output : 1682 : Get End Date : 1683 : Derived Column Input : 641 4/8/2008 10:24 4/8/2008 10:24 Rows were provided to a data flow component as input. : : 1702 : Derived Column Output : 1692 : Update End Date : 1697 : OLE DB Command Input : 641 4/8/2008 10:26 4/8/2008 10:26 Rows were provided to a data flow component as input. : : 1759 : OLE DB Command Output : 1715 : Union All : 1758 : Union All Input 2 : 641 4/8/2008 10:26 4/8/2008 10:26 Rows were provided to a data flow component as input. : : 2970 : DataReader Output : 70 : Slowly Changing Dimension : 81 : Slowly Changing Dimension Input : 9947 4/8/2008 10:49 4/8/2008 10:49 Rows were provided to a data flow component as input. : : 1718 : New Output : 1715 : Union All : 1716 : Union All Input 1 : 3969 4/8/2008 10:49 4/8/2008 10:49 Rows were provided to a data flow component as input. : : 1688 : Historical Attribute Inserts Output : 1682 : Get End Date : 1683 : Derived Column Input : 662 4/8/2008 10:49 4/8/2008 10:49 Rows were provided to a data flow component as input. : : 1702 : Derived Column Output : 1692 : Update End Date : 1697 : OLE DB Command Input : 662 4/8/2008 10:49 4/8/2008 10:49 Rows were provided to a data flow component as input. : : 1793 : Union All Output 1 : 1787 : Get Start Date : 1788 : Derived Column Input : 9947 4/8/2008 10:49 4/8/2008 10:49 Rows were provided to a data flow component as input. : : 1814 : Derived Column Output : 1797 : Insert Destination : 1810 : OLE DB Destination Input : 9947 4/8/2008 15:34 4/8/2008 15:34 The pipeline received a request to cancel and is shutting down. 4/8/2008 15:34 4/8/2008 15:34 Thread "WorkThread1" received a shutdown signal and is terminating. The user requested a shutdown or an error in another thread is causing the pipeline to shutdown. 4/8/2008 15:34 4/8/2008 15:34 Thread "WorkThread1" received a shutdown signal and is terminating. The user requested a shutdown or an error in another thread is causing the pipeline to shutdown. 4/8/2008 15:34 4/8/2008 15:34 The pipeline received a request to cancel and is shutting down. 4/8/2008 15:34 4/8/2008 15:34 Thread "WorkThread1" has exited with error code 0xC0047039. 4/8/2008 15:34 4/8/2008 15:34 Thread "WorkThread1" has exited with error code 0xC0047039.
Notice the time difference between the last OnPipelineRowsSent event and the first OnError event (when I clicked the stop button): 5 hours! In all that time, SSIS did not log a single event, or use more than 2% of my processor or exceed 1GB page file or hit the database even once! I am assuming this means it is simply not doing anything. It is not failing, nor is it executing, it is just sitting there.
Has anyone experienced a similar problem? Does anyone know how I might troubleshoot this? Thanks in advance for any help, and let me know if I need to clarify. Also, I am new to SSIS, so if I am missing something obvious, go easy on me! Thanks.
I am new in Crystal reports so please help me on this one.
I have to create a report that will bring back the TOP 20 customers per Sales Rep. My SQL stored procedure needs a parameter @SalesRep to execute. My stored procedure links between 2 tables. How do I get this stored procedure executed in Crysal Reports to give me results. The SP works fine.
I'm working on a stored procedure to populate a Crystal report. My company insists that we put the report parameters in the stored procedure instead of in Crystal...so that the SQL server (rather than the desktop)does the work of restricting the data. Is there anything I can do on the SQL side(possibly User Defined Data Type) to get Crystal to prompt me for a date WITHOUT the time? I started with this:
When Crstal prompts me for the parameters, I can type the date or use the calendar to pick a date, but I AM FORCED to enter a time. I know I could choose to ignore the time in the stored procedure, but the users don't want to see the time section of the parameter. Apparently SQL doesn't have a plain "date" parameter without a time.
However if I do it this way, I can't seem to find a way to make sure a valid date is entered when Crystal prompts the user for the dates.
If using char(10) turns out to be the best method, is there a way I can pre-populate the Crystal prompts like this: @BeginDate = 1st day of the current month @EndDate = the current system date
Crystal seems to allow hard coded default values, but I can't find a way to do calculated default values.
I've tried to find this documented on the Internet and found Crystal Reports User's Guid online documentation (582 pages of it!) It looks like it will be helpful for my other questions, but what I'm trying to do right now is call a stored procedure from my crystal report. So in Field Explorer under Database Fields my stored procedure is there with the three columns it selects. How do I put these three columns on my report? I try dragging them to Section 3 details and they're there but when I preview the report all I get are the headers, not the records. Is there something else I need to do? It requires an input parameter which I am not getting prompted for - maybe that is my problem, without an input parameter it can't successfully run the stored procedure, so how do I make it prompt me?
Thanks for helping me with my first Crystal Report!
i am developing a Performance Management System for my organisation and reports are quite complex. so i thought to create a CLR stored procedure and then use this in Crystal Report.
The problem I am facing is that the CLR stored procedures I create using Visual Studio 2005 are not visible from Crystal Reports XI come with Visual Studio 2005. I can create stored procedures using standard transact sql and these are visible, but the CLR stored procedures are not.
I Simply create a CLR store procedure in Visual Basic and debug it. This CLR procedure then appeares under stored procedure node in SQL Server 2005.
I've noticed when I browse the stored procedures in my SQL Management Studio that the image of the stored procedure has a padlock shown in the icon, as if they are locked?
Do I have to explicitly enable a security attribute on CLR stored procedures to make them visible?
Hello:I have a stored procedure for generating our invoices in CrystalReports. I have added a new field to the SP, but when I try to add thefield to my Crystal Report invoice, the field isn't available in thelist. However, if I create a new, blank report using the same storedprocedure as the datasource, the field is available. I've seeminglytried every iteration of "Verify Database" to no avail.The obvious answer would be to simply drop the sp from my existingreport and then re-add it. However, if you do this, all your fields onthe report are dropped.Any ideas?Thanks,Scott
Situation: If possible, create one stored procedure for Crystal Reports(CR). For any CR users ou there, looking for coding suggestion also. Thank you for your assistance.
Currently, CR has a header(Report Header) coming from 1 to 1 tables, there is a parameter which is passed in, allowing it to retrieve one record for the header(report header or RH).
The CR then has 4 subreports in which each has its own stored procedure. This I believe happens because the Report Header records relationship to the subreport is 1 to many. The 3 remaining subreports relationship to the Report Header is also a 1 to many. The main problem is the subreports is that there may or may not have any records based on this, the subreport is suppressed within CR and thus there can be alot of unused white space on the 1st page and one of the subreports prints on a 2nd page when it could have been on the 1st page.
Example:
Main Stored Procedure(sp) RH Tables: aaa, bbb, ccc, ddd are 1 to 1 record tables and have a @xyz parameter.
Results of subreports and their associated procedure are varchar(8000) decriptions. Each line should be counted in some manner in the stored procedure(sp) and then should be counted in CR to avoid excess white space. To complicate matters subreport 2 to has font, bold, showbox but can have different font sizes. These variations could cause different line space requirements. Any ideas?
Each line should be counted in some manner in the stored procedure and then should be counted in CR. There is a count of records for each the main stored procedure.
RH has 1 record to many records in subreport 1 with same @xyz parameter. RH has 1 record to many records in subreport 2 with same @xyz parameter. RH has 1 record to many records in subreport 3 with same @xyz parameter. RH has 1 record to many reords in subreport 4 with same @xyz parameter.
Because of the relationships, its seems impossible to create one stored procedure which give in one select statement with all the 1 to 1, 1 to many relationsips, as stated above. I thought concatinating i.e. 3 records together and then parsing it out some how in CR, along with utilizing the i.e. 3 record count to help count lines. Thought of some how creating a temporary table matrix for 8pt - 28pt for line and spacing considerations.
We're having problems with a number of stored procedures we have written (we're all v. new to SQL Server). The typical scenario is :
sp executes spA,spB and spC Each uses a cursor, spA,spB and spC out values that sp wants to output with some additional info.
In ISQL/W the output is fine. When the sp is executed from a Crystal Report we always get a single row of data (the 1st). We get the same problem if it is executed from the Access Upsizing Tool's SQL Server Browser utility.
We use SET NOCOUNT ON in sp (not in the others). If we remove SET NOCOUNT ON we get now rows in Crystal.
I enclose an example (with 3 sub- SPs). Help. Martin
--output from qryEmployeeNICHol @SumOfdEmployersNICHoliday FLOAT
SET NOCOUNT ON
DECLARE employee_period CURSOR FOR SELECT tblEmployees.lUniqueID, tblEmployees.lEmployeeNumber, tblEmployees.szEmployeeSurname, tblEmployees.szInitials, tblEmployees.szDeptNo, tblEmployees.dtDateLeft, tblEmployees.dTotalGrossPayThis, tblEmployees.dTaxableGrossPayThis, tblEmployees.dTotalGrossPayPrevious, tblEmployees.dTaxableGrossPayPrevious, tblEmployees.dTaxPaidThis AS EdTaxPaidThis, tblEmployees.dTaxPaidPrevious, tblEmployees.dSMPPaidToDate, tblEmployees.dSSPPaidToDate FROM tblEmployees WHERE (tblEmployees.lCompanyNumber = @lQryCompanyNumber)
DECLARE employee_ni_categories SCROLL CURSOR FOR SELECT DISTINCT tblEmployeePeriodDetails.lUniqueID, tblEmployeePeriodDetails.cNICategory FROM tblEmployeePeriodDetails WHERE ((tblEmployeePeriodDetails.lUniqueID = @lUniqueID) AND (tblemployeePeriodDetails.dtPeriodEndDate >= @dtQryPayrollYearStartDate))
OPEN employee_period
FETCH NEXT FROM employee_period INTO @lUniqueID, @lEmployeeNumber, @szEmployeeSurname, @szInitials, @szDeptNo, @dtDateLeft, @EdTotalGrossPayThis, @EdTaxableGrossPayThis, @EdTotalGrossPayPrevious, @EdTaxableGrossPayPrevious, @EdTaxPaidThis, @EdTaxPaidPrevious, @EdSMPPaidToDate, @EdSSPPaidToDate
WHILE (@@FETCH_STATUS <> -1) BEGIN EXEC qryPayEmp8b @lUniqueID, @dtQryPayrollYearStartDate, @SumOfdEmployersNICHoliday OUTPUT EXEC qryPayEmp8c @lUniqueID, @dtQryPeriodEndDate, @PdTotalGrossPayThis OUTPUT, @PdTaxableGrossPayThis OUTPUT, @PdTaxPaidThis OUTPUT, @PdSMPPaid OUTPUT, @PdSSPPaid OUTPUT OPEN employee_ni_categories FETCH FIRST FROM employee_ni_categories INTO @lCCUniqueID, @szNICategory IF (@@FETCH_STATUS <> -1) WHILE (@@FETCH_STATUS <> -1) BEGIN EXEC qryPayEmp8a @lUniqueID, @szNICategory, @dtQryPayrollYearStartDate, @SumOfdNIablePay OUTPUT, @SumOfdEmployersNI OUTPUT, @SumOfdEmployeeNI OUTPUT, @SumOfdContractedOutEarnings OUTPUT, @SumOfdEmployeeNIContractedOut OUTPUT
SELECT @lUniqueID AS lUniqueID, @lEmployeeNumber AS lEmployeeNumber, @szEmployeeSurname AS szSurname, @szInitials AS szInitials, @szDeptNo AS szDeptNo, @dtDateLeft AS dtDateLeft, @EdTotalGrossPayThis AS EdTotalGrossPayThis, @EdTaxableGrossPayThis AS EdTaxableGrossPayThis, @EdTotalGrossPayPrevious AS EdTotalGrossPayPrevious, @EdTaxableGrossPayPrevious AS EdTaxableGrossPayPrevious, @EdTaxPaidThis AS EdTaxPaidThis, @EdTaxPaidPrevious AS EdTaxPaidPrevious, @EdSMPPaidToDate AS EdSMPPaidToDate, @EdSSPPaidToDate AS EdSSPPaidToDate, @SumOfdEmployersNICHoliday AS SumOfdEmployersNICHoliday, @PdTotalGrossPayThis AS PdTotalGrossPayThis, @PdTaxableGrossPayThis AS PdTaxableGrossPayThis, @PdTaxPaidThis AS PdTaxPaidThis, @PdSMPPaid AS PdSMPPaid, @PdSSPPaid AS PdSSPPaid, @szNICategory AS szNICategory, @SumOfdNIablePay AS SumOfdNIablePay, @SumOfdEmployersNI AS SumOfdEmployersNI, @SumOfdEmployeeNI AS SumOfdEmployeeNI, @SumOfdContractedOutEarnings AS SumOfdContractedOutEarnings, @SumOfdEmployeeNIContractedOut AS SumOfdEmployeeNIContractedOut
FETCH NEXT FROM employee_ni_categories INTO @lCCUniqueID, @szNICategory END ELSE SELECT @lUniqueID AS lUniqueID, @lEmployeeNumber AS lEmployeeNumber, @szEmployeeSurname AS szSurname, @szInitials AS szInitials, @szDeptNo AS szDeptNo, @dtDateLeft AS dtDateLeft, @EdTotalGrossPayThis AS EdTotalGrossPayThis, @EdTaxableGrossPayThis AS EdTaxableGrossPayThis, @EdTotalGrossPayPrevious AS EdTotalGrossPayPrevious, @EdTaxableGrossPayPrevious AS EdTaxableGrossPayPrevious, @EdTaxPaidThis AS EdTaxPaidThis, @EdTaxPaidPrevious AS EdTaxPaidPrevious, @EdSMPPaidToDate AS EdSMPPaidToDate, @EdSSPPaidToDate AS EdSSPPaidToDate, @SumOfdEmployersNICHoliday AS SumOfdEmployersNICHoliday, @PdTotalGrossPayThis AS PdTotalGrossPayThis, @PdTaxableGrossPayThis AS PdTaxableGrossPayThis, @PdTaxPaidThis AS PdTaxPaidThis, @PdSMPPaid AS PdSMPPaid, @PdSSPPaid AS PdSSPPaid CLOSE employee_ni_categories FETCH NEXT FROM employee_period INTO @lUniqueID, @lEmployeeNumber, @szEmployeeSurname, @szInitials, @szDeptNo, @dtDateLeft, @EdTotalGrossPayThis, @EdTaxableGrossPayThis, @EdTotalGrossPayPrevious, @EdTaxableGrossPayPrevious, @EdTaxPaidThis, @EdTaxPaidPrevious, @EdSMPPaidToDate, @EdSSPPaidToDate END
CLOSE employee_period DEALLOCATE employee_period
DEALLOCATE employee_ni_categories RETURN
-----------------
CREATE PROCEDURE coral.qryPayEmp8a @lUniqueID INT = 1, @szNICategory VARCHAR (1) = 'A', @dtPayrollYearStartDate DATETIME = '1900-01-01 00:00:00.000', @SumOfdNIablePay FLOAT OUTPUT, @SumOfdEmployersNI FLOAT OUTPUT, @SumOfdEmployeeNI FLOAT OUTPUT, @SumOfdContractedOutEarnings FLOAT OUTPUT, @SumOfdEmployeeNIContractedOut FLOAT OUTPUT AS SELECT DISTINCT @SumOfdNIablePay = Sum(tblEmployeePeriodDetails.dNIablePay), @SumOfdEmployersNI = Sum(tblEmployeePeriodDetails.dEmployersNI), @SumOfdEmployeeNI = Sum(tblEmployeePeriodDetails.dEmployeeNI), @SumOfdContractedOutEarnings = Sum(tblEmployeePeriodDetails.dContractedOutEarning s), @SumOfdEmployeeNIContractedOut = Sum(tblEmployeePeriodDetails.dEmployeeNIContracted Out) FROM tblEmployeePeriodDetails WHERE ((tblEmployeePeriodDetails.lUniqueID = @lUniqueID) AND (tblEmployeePeriodDetails.cNICategory = @szNICategory) AND (tblEmployeePeriodDetails.dtPeriodEndDate >= @dtPayrollYearStartDate)) GROUP BY tblEmployeePeriodDetails.lUniqueID, tblEmployeePeriodDetails.cNICategory
RETURN
-----------------------------
REATE PROCEDURE coral.qryPayEmp8b @lQryUniqueID INT = 1, @dtQryPayrollYearStartDate DATETIME = '1900-01-01 00:00:00.000', @SumOfdEmployersNICHoliday FLOAT OUTPUT AS SELECT @SumOfdEmployersNICHoliday = Sum(tblEmployeePeriodDetails.dEmployersNIforNICHol iday) FROM tblEmployeePeriodDetails WHERE ((tblEmployeePeriodDetails.lUniqueID = @lQryUniqueID) AND (tblEmployeePeriodDetails.dtPeriodEndDate >= @dtQryPayrollYearStartDate))
FROM tblEmployeePeriodDetails WHERE ((tblEmployeePeriodDetails.lUniqueID = @lQryUniqueID) AND (tblEmployeePeriodDetails.dtPeriodEndDate = @dtQryPeriodEndDate))
Hi i have the following stored procedure, i am trying to convert it to inline sql, however i got stuck, because how would i output a value e.g "@Access_Right_ID", this is the stored procedure below CREATE PROCEDURE dhoc_AccessRight_Insert @AccessLevel char(50), @Access_Right_ID int OUT, @Tstamp timestamp out ASSELECT * FROM tblAccess_Right WHERE AccessLevel = @AccessLevel IF @@ROWCOUNT <>0 BEGIN RAISERROR('This record is already in the database',16,1) RETURN 14 END ELSE BEGIN SET NOCOUNT OFF; INSERT INTO tblAccess_Right ( AccessLevel ) VALUES (@AccessLevel); SET @Access_Right_ID = @@Identity SET @Tstamp = (SELECT Tstamp FROM tblAccess_Right WHERE Access_Right_ID=@Access_Right_ID) --Make sure this has saved, if not return 10 as this is unexpected error IF @@rowcount = 0 BEGIN RAISERROR('This record has not been inserted at this time, it might have been inserted by another user, please try again',16,1) RETURN 10 END ELSE BEGIN IF @@error <>0 BEGIN RETURN @@error END ENDEND GO
I need to create a stored procedure in the master database that canaccess info to dynamically create a view in another database. Itdoesn't seem like it should be very hard, but I can't get it to work.Here's an example of what I want to do.CREATE PROCEDURE create_view @dbname sysnameASBEGINDECLARE @query varchar(1000)SELECT @query = 'use ' + @dbname + ' go CREATE VIEW ........'EXEC(@query)ENDIn this case, I get an error with the word "go". Without it, I get a"CREATE VIEW must be the first statement in a batch" error. I tried asemicolon in place of "GO" but that didn't help either.Thanks
After I changed the activation stored procedure of a queue, the old activation stored procedure keeps being launched by the service associated with the queue. I turned the queue off and on, but to no avail. I also checked the dynamic view sys.service_queues to make sure the proper stored procedure exists in the field activation_procedure. Do you have any idea about what might have gone wrong?
I have a stored proc which will be fed a value that is compared to a char value for a selection. One of the choices might be 'all' for which I want to return all records. Something like this
create procedure name @location char(40) as select ----------------
where locname like @location
I tried using LIKE COALESCE but no luck. Any ideas Thanks
I import a flat file from a legacy system, and then convert it into a single table. That works simply enough.
Then I have a SP that querys that table using a parameter for an accountID. My business tier calls that SP and returns the results to the calling tier (my web application). Easy enough...
Now for the question. The people who created the flat file (written in COBOL) decided to use "codes" to represent data. So, for instance, if I'm looking for the account plan, I can expect to see characters like ], or [, or +, etc... These characters have a special meaning, like:
] = Plan A [ = Plan B + = Plan C, and so on.
Currently, the web application displays those characters, but I want it to display the actual plan name. Is there a way that when I execute the SP, the SP could pull the necessary records, and whenever it encounters a certain "plan" character, it could convert it into a "readable" name? Say that it sees that the plan_type field has a value of "]" for twenty records, so it converts those twenty records' plan_type value from "]" into "Plan A"? I'm not sure if I can do that, but I want to at least evaluate the option if I can.
I've evaluated other options, like using a CASE statement in my code, but I shot that down quickly...for obvious reasons. I don't wanna be changing my web application or business tier each time these guys update a plan name, or add a new one, delete an existing one, etc...
I've also thought about creating a dictionary table than contains the plan's code and its name, and then just INNER JOIN the first table with the dict table. This would keep my SP very simple (it's very straight-forward right now, and I like that). That way, if a plan name is ever changed, or a new one is added, I simply update the dict table using a simple query. However, if my SP is doing the conversion, I could just as easily update the SP.
Either of these methods would work for me, and I *do* know how to do the latter (dict table). However, there are quite a few other fields that I may have to do this for. I believe when I left for the day on Friday, my last count was 14 fields total that needed translation. That would mean 14 different dict tables! That could certainly affect my SP performance with all those INNER JOINS!
Therefore, I'm certainly interested in figuring out if it's possible to do the former method (SP), and then I shall decide which method is best for my situation.
Feel free to include your thoughts on which process you think is better as well. I'm really riding the fence with this one. However, if I can't find out how to change field values in my SP, then obviously I'll make a decision very quickly...
The SQL Server is running full recovery model but they would like it to be changed to simple while the data backup occurs then set back to full. Is there a way to do this in a stored procedure or is it all done via options ? Thanks
If I have a column named "Login" in a SQL Table (I am sharing with another application) that I am using a stored procedure to acquire the information from, how can I trranspose its name to match code already written in a Web App to get the data. There is a web app already created that has the followig code to get the data from the database Dim strSQL ast string = "UsersSelectCommand" intLoginID = objDataReader("LoginID")
My stored procedure is the following: CREATE PROCEDURE UsersSelectCommand/* ( @parameter1 datatype = default value, @parameter2 datatype OUTPUT )*/AS Select Lastname, FirstName, Login from Users Order by LastName GO The stored procedure will return "Login" instead of "LoginID" that I am wanting. How can I modify the Stored Procedure to change the LoginID to Login.
Hello everyone,I need advice of how to accomplish the following:Loop though records in a table and send an email per record. Emailrecipient, message text and attachment file name - that's all changesrecord by record.Is it doable from a stored procedure (easily I mean, or am I better offwriting a VB app)? There are so many options of sending mail from SQLserver - CDONTS, SQL MAIL TASK, xp_sendmail. What's easier to implementand set up?Thanks a lot!!!(links and fragments of sample code would be greatlyappreciated)Larisa
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?
I executed them and got the following results in SSMSE: TopSixAnalytes Unit AnalyteName 1 222.10 ug/Kg Acetone 2 220.30 ug/Kg Acetone 3 211.90 ug/Kg Acetone 4 140.30 ug/L Acetone 5 120.70 ug/L Acetone 6 90.70 ug/L Acetone ///////////////////////////////////////////////////////////////////////////////////////////// Now, I try to use this Stored Procedure in my ADO.NET-VB 2005 Express programming: //////////////////--spTopSixAnalytes.vb--///////////
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlConnection As SqlConnection = New SqlConnection("Data Source = .SQLEXPRESS; Integrated Security = SSPI; Initial Catalog = ssmsExpressDB;")
Dim sqlDataAdapter As SqlDataAdapter = New SqlDataAdaptor("[spTopSixAnalytes]", sqlConnection)
'Pass the name of the DataSet through the overloaded contructor
'of the DataSet class.
Dim dataSet As DataSet ("ssmsExpressDB")
sqlConnection.Open()
sqlDataAdapter.Fill(DataSet)
sqlConnection.Close()
End Sub
End Class ///////////////////////////////////////////////////////////////////////////////////////////
I executed the above code and I got the following 4 errors: Error #1: Type 'SqlConnection' is not defined (in Form1.vb) Error #2: Type 'SqlDataAdapter' is not defined (in Form1.vb) Error #3: Array bounds cannot appear in type specifiers (in Form1.vb) Error #4: 'DataSet' is not a type and cannot be used as an expression (in Form1)
Please help and advise.
Thanks in advance, Scott Chang
More Information for you to know: I have the "ssmsExpressDB" database in the Database Expolorer of VB 2005 Express. But I do not know how to get the SqlConnection and the SqlDataAdapter into the Form1. I do not know how to get the Fill Method implemented properly. I try to learn "Working with SELECT Statement in a Stored Procedure" for printing the 6 rows that are selected - they are not parameterized.
I have some code that I need to run every quarter. I have many that are similar to this one so I wanted to input two parameters rather than searching and replacing the values. I have another stored procedure that's executed from this one that I will also parameter-ize. The problem I'm having is in embedding a parameter in the name of the called procedure (exec statement at the end of the code). I tried it as I'm showing and it errored. I tried googling but I couldn't find anything related to this. Maybe I just don't have the right keywords. what is the syntax?
CREATE PROCEDURE [dbo].[runDMQ3_2014LDLComplete] @QQ_YYYY char(7), @YYYYQQ char(8) AS begin SET NOCOUNT ON; select [provider group],provider, NPI, [01-Total Patients with DM], [02-Total DM Patients with LDL],
My SQL Server production DB freezes for 20 minute periods about 3 times a day, during this time no-one can do anything. I checked the perf. monitor counters (all the ones there at default), the scary part is that they ALL fall to 0 during the freeze, then rise to normal. Yes, that's zero %!
I checked the ID's connecting, there are no common ones that connect just before a freeze, and there are no hardware issues. It's only a 400Mb DB, with a trans log of 120Mb. Between 200-400 users are connected during business hours, both from the LAN and off. Some users are running some fairly heavy reports, but there's no correlation between these and the freezes. The biggest table only has 1.5 million rows, and the average query time is 232 milliseconds.
This whole mess has been going on since the 15th of Jan, we searched high and low for any alterations made, but the client swears blind that no changes were made. Any ideas anyone?
Hi, the SQL DB freezes and no one can access the DB for 5 or 10 minutes. Even select queries don t execute, nothing is displayed.
Until we kill the process id that s blocking in the sql activity monitor, only then the DB is released and people can work again. What does it mean that no query executes until we kill the processes ID? what could it be?
Also, recently we created indexes and ran tuning adviser, is it possible that the creation of indexes cause the freeze of a DB? is that possible?
I have a sub that passes values from my form to my stored procedure. The stored procedure passes back an @@IDENTITY but I'm not sure how to grab that in my asp page and then pass that to my next called procedure from my aspx page. Here's where I'm stuck: Public Sub InsertOrder() Conn.Open() cmd = New SqlCommand("Add_NewOrder", Conn) cmd.CommandType = CommandType.StoredProcedure ' pass customer info to stored proc cmd.Parameters.Add("@FirstName", txtFName.Text) cmd.Parameters.Add("@LastName", txtLName.Text) cmd.Parameters.Add("@AddressLine1", txtStreet.Text) cmd.Parameters.Add("@CityID", dropdown_city.SelectedValue) cmd.Parameters.Add("@Zip", intZip.Text) cmd.Parameters.Add("@EmailPrefix", txtEmailPre.Text) cmd.Parameters.Add("@EmailSuffix", txtEmailSuf.Text) cmd.Parameters.Add("@PhoneAreaCode", txtPhoneArea.Text) cmd.Parameters.Add("@PhonePrefix", txtPhonePre.Text) cmd.Parameters.Add("@PhoneSuffix", txtPhoneSuf.Text) ' pass order info to stored proc cmd.Parameters.Add("@NumberOfPeopleID", dropdown_people.SelectedValue) cmd.Parameters.Add("@BeanOptionID", dropdown_beans.SelectedValue) cmd.Parameters.Add("@TortillaOptionID", dropdown_tortilla.SelectedValue) 'Session.Add("FirstName", txtFName.Text) cmd.ExecuteNonQuery() cmd = New SqlCommand("Add_EntreeItems", Conn) cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add("@CateringOrderID", get identity from previous stored proc) <------------------------- Dim li As ListItem Dim p As SqlParameter = cmd.Parameters.Add("@EntreeID", Data.SqlDbType.VarChar) For Each li In chbxl_entrees.Items If li.Selected Then p.Value = li.Value cmd.ExecuteNonQuery() End If Next Conn.Close()I want to somehow grab the @CateringOrderID that was created as an end product of my first called stored procedure (Add_NewOrder) and pass that to my second stored procedure (Add_EntreeItems)
I have a stored procedure and in that I will be calling a stored procedure. Now, based on the parameter value I will get stored procedure name to be executed. how to execute dynamic sp in a stored rocedure
at present it is like EXECUTE usp_print_list_full @ID, @TNumber, @ErrMsg OUTPUT
I want to do like EXECUTE @SpName @ID, @TNumber, @ErrMsg OUTPUT
Hi have a package with 3 steps : 1 - import data from flat file into a temp table 2 - copy selected data from the temp table to permanent tables 3 - truncate temp table
The task #2 is a SQL statement
INSERT INTO MODELS (MODEL_ID) SELECT DISTINCT MATNR FROM STANDARD WHERE MATNR NOT IN (SELECT MODEL_ID FROM MODELS)
where STANDARD is the temp table and MODELS a permanent one. My problem is this simple task freezes all the time. It stalls on 'Starting' and stays in this state forever when I execute the package.