How To Change The Sql Queries Generated Internally

May 3, 2007

We are trying a cluster setup on MS SQL 2005 with one m/c as Publisher (Primary) and another as Subscriber (Secondary).

When Publisher and Subscriber both are running, everything goes fine but when Publisher server goes down, subscriber server troubles.



We are using MSADO15.DLL for database connectivity.

We have a table where ID column is set to primary key with Auto Increment true.

We use AddNew() function of this library to insert a new record.

We fill a structure with all necessary values to pass it to AddNew() with ID field set to 0.

When we use AddNew() on the above table to insert a record, the ID auto inserted in table is correct but returned structure contains wrong ID value.



We tried to trace this problem using SQL Server Profiler Tool of SQL Server.

AddNew() function performs following operations in back end

1. Inserts the record to the table using INSERT

2. Calculates the auto increment field ID using SELECT @@IDENTITY

3. Fills this ID in the structure passed to AddNew() and returns it.

But ID returned by SELECT @@IDENTITY query is wrong.

There are other ways also to retrieve the last ID inserted in table by

IDENT_CURRENT(‘table_name’) which return right ID.



Can we change the call of SELECT @@IDENTITY to IDENT_CURRENT in AddNew() functions behavior of MSADO DLL?

Or there is another way of retrieving right ID?

View 1 Replies


ADVERTISEMENT

How To Change The Sql Queries Generated Internally

May 3, 2007

We are trying a cluster setup on MS SQL 2005 with one m/c as Publisher (Primary) and another as Subscriber (Secondary).

When Publisher and Subscriber both are running, everything goes fine but when Publisher server goes down, subscriber server troubles.



We are using MSADO15.DLL for database connectivity.

We have a table where ID column is set to primary key with Auto Increment true.

We use AddNew() function of this library to insert a new record.

We fill a structure with all necessary values to pass it to AddNew() with ID field set to 0.

When we use AddNew() on the above table to insert a record, the ID auto inserted in table is correct but returned structure contains wrong ID value.



We tried to trace this problem using SQL Server Profiler Tool of SQL Server.

AddNew() function performs following operations in back end

1. Inserts the record to the table using INSERT

2. Calculates the auto increment field ID using SELECT @@IDENTITY

3. Fills this ID in the structure passed to AddNew() and returns it.

But ID returned by SELECT @@IDENTITY query is wrong.

There are other ways also to retrieve the last ID inserted in table by

IDENT_CURRENT(‘table_name’) which return right ID.



Can we change the call of SELECT @@IDENTITY to IDENT_CURRENT in AddNew() functions behavior of MSADO DLL?

Or there is another way of retrieving right ID

View 1 Replies View Related

How To Change The Sql Queries Generated Internally By Functions Supported By MSADO Dll For MS SQL Server2005

May 3, 2007

We are trying a cluster setup on MS SQL 2005 with one m/c as Publisher (Primary) and another as Subscriber (Secondary).
When Publisher and Subscriber both are running, everything goes fine but when Publisher server goes down, subscriber server troubles.

We are using MSADO15.DLL for database connectivity.
We have a table where ID column is set to primary key with Auto Increment true.
We use AddNew() function of this library to insert a new record.
We fill a structure with all necessary values to pass it to AddNew() with ID field set to 0.
When we use AddNew() on the above table to insert a record, the ID auto inserted in table is correct but returned structure contains wrong ID value.

We tried to trace this problem using SQL Server Profiler Tool of SQL Server.
AddNew() function performs following operations in back end
1. Inserts the record to the table using INSERT
2. Calculates the auto increment field ID using SELECT @@IDENTITY
3. Fills this ID in the structure passed to AddNew() and returns it.
But ID returned by SELECT @@IDENTITY query is wrong.
There are other ways also to retrieve the last ID inserted in table by
IDENT_CURRENT(€˜table_name€™) which return right ID.

Can we change the call of SELECT @@IDENTITY to IDENT_CURRENT in AddNew() functions behavior of MSADO DLL?
Or there is another way of retrieving right ID?

View 3 Replies View Related

Optimizing Queries Generated At Runtime

Sep 5, 2007

Hi

We are using SQL SERVER 2005, enterprise/standard edition for an application that generates queries at runtime and normally having many joins in it. But these queries are taking lot of time when they are executed. After setting the database parameter PARAMETERIZATION to FORCED, performance of the queries have improved a lot but still we want to improve them further. Is there any other parameter that we can set for improving the performance of the queries. We have created the indexes on the basic columns that will be used while querying but it may happen that some other columns may also be used for searching in which case queries become quiet slow. Is there anything like skip-scan indexes(of oracle) in sql server 2005.

Regards
Salil

View 4 Replies View Related

Change Report Is Being Generated

Feb 20, 2006

Hello,

I develop some application using SQL Server Reporting Services 2005 to Russian customers. They usually don't know English well. That's why I really want to change phrase "Report is being generated" to Russian words.
How can I do it? I tried to fing this phrase in configuration files or registry but there wasn't success.

Thank you,

View 17 Replies View Related

Different Queries In Different Sheets Of The Same Excel Work Book For A Report Generated In SSRS 2005

Apr 23, 2008

i need to get the result of two different queries into 2 different sheets of the same excel file while exporting a report to excel using reporting services..

somebody please help

View 1 Replies View Related

Saving Tables That Are Generated By Queries As HTML File Or Sub-tables

Oct 17, 2006

I have a trade data tables (about 10) and I need to retrieve information based on input parameters. Each table has about 3-4 million rows.

The table has columns like Commodity, Unit, Quantity, Value, Month, Country

A typical query I use to select data is "Select top 10 commodity , sum(value), sum(quantity) , column4, column5, column6 from table where month=xx and country=xxxx"

The column4 = (column2)/(total sum of value) and column 5=(column3)/(total sum of quantity). Column6=column5/column4.

It takes about 3-4 minutes for the query to complete and its a lot of time specially since I need to pull this information from a webpage.

I wanted to know if there is an alternate way to pull the data from server ?

I mean can I write a script that creates tables for all the input combinations i.e month x country (12x228) and save them in table (subtable-table) with a naming convention so from the web I can just pull the table with input parameters mapped to name convention and not running any runtime queries on database ??

OR

Can I write a script that creates a html files for each table for all input combinations save them ?

OR

Is there exists any other solution ?

View 1 Replies View Related

Dynamically Change The DataFlow Queries

Mar 20, 2006

Hi Guys,

This is Ravi. I'm working on SSIS 2005 version. I have created the DTSX file from the SQL Server and executed it successfully from my .NET 2005 code.

Now I have a requirement that I need to dynamically change the Source database query. ie., based on the user selection I need to get the data from different tables of SQL and put it into an Excel file.

Can anyone help me in this..

Regards,
Ravi K. Kalyan
Mascon Global Limited.

View 2 Replies View Related

Will Change In Index Slows Down Queries In SQL Server2000 Sp4.

May 12, 2008



Hi

Will change in index slows down queries in SQL Server2000 sp4.

Please help me

View 4 Replies View Related

Two Count Queries - Calculate % Change In Number Of Orders

Mar 12, 2015

I have a requirement to calculate the % change in the number of orders received today with the number of orders that were received 3 days back. All data is in the same table. There is a received date column.

I have two count(*) queries - one for today and one for 3 days back running separately and getting the results. Is it possible I can get the % change in orders received from 3 days back and today in one query.Also if I want to get the number of orders received today between 12:00am today and current time. How would I modify the query.

View 2 Replies View Related

Change Connected User To Avoid Owner Prefix In Queries

Mar 16, 2007

Hi everybody,I've five instances of SQL Server 2000 with the SAME database with aDIFFERENT owner in each server. I, as the administrator, have a lot ofqueries that I have to execute in some or all servers. The problem isthat I have to connect to all servers with MY user, not each of the dbowners...So I have queries this way:select * from mike.table1 t1 join mike.table2 t2 on...And when I connect to another server I have to change mike for jeremyin all the SQLs...And when I connect to another server I have to change jeremy for ninain all the SQLs...I know that there was an old, v7, deprecated way to change the"schema", something likechange current user to kimberlygoselect * from table1 t1 join table2 t2 on...This way, I'll change ONLY once the connected user. I could even do atthe beginning of the script an IF, to change the connected userdepending on @@SERVERNAME !!!Can someone remember this instruction???Thanks in advance for your help !!!

View 1 Replies View Related

Internally Convert To GMT?

Sep 25, 2006

Hi there,Can SQL Server 2005 be made to report the date as GMT using the getDate() function? (without changing the local time on the box that it's installed on?)If I could get the current offset value within a Stored Procedure that would help.. Thank you! 

View 1 Replies View Related

Entity Framework: No Support For Server-generated Keys And Server-generated Values

May 23, 2008

Hello

I tried the Beta 1 of the service pack 1 to .net 3.5. If I try to add an entity (and try to save this), I get the Exception "No support for server-generated keys and server-generated values".

How can I add entities to my Sqlce- database?

I tried to give the id- column (primary key) in the database an identity, another time without identity, only primary key --> none of them worked. I always get the same error.

What do I have to change to make successfully a SaveChanges()?

Thanks for your help,
Gerald

View 21 Replies View Related

How Data Is Inserted Into Table Internally

Nov 2, 2015

I would like to know how data is inserted and selected from table internally. Like how buffers are created and how they are executed.

Eg. Table1 
col1 col2 col3
1 a 1
2 b 2

I want to know how this data is inserted into tables. How many buffers are created ? Does it depends on the columns? How buffers are executed? 

View 7 Replies View Related

Clean Text Files Externally Or Internally

May 17, 2008

Quick history, I have substantial experience using MS Access, VBA, and Regular Expressions to clean up messy text files for use in MS Access.

I want to upgrade an MS Access back end to SQL Server (2008 to be specific). I need to upload several delimited files on a daily basis. The files are full of formatting that I strip out using VBA and Regular Expressions. I've poked around on the site and found some UDFs that implement the VbScript Regular Expressions object as a stored procedure in Transact SQL.

My questions is, am I better off processing the files externally using a procedural language like VB or can SQL Server handle the processing as gracefully as MS Access/VBA/RegEx does?

Thanks for letting me tap into your experience.

I could simply puzzle it out myself by implementing it in SQL Server but I'd rather not waste the time as a newb to transact SQL and then find out that I'd be better off doing it externally.

J--

View 1 Replies View Related

Working With SQL 2005 Interface But Internally It Works As SQL 2000

Aug 27, 2007

Hi! I have installed SQL 2000 and SQL 2005 in my computer.I tried to use some new features like row_number(),try..catch.. but are not working giving syntax error.� So someone told me that i had to check the version and when I cheked I realized I was working with SQL 2000: “Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48 Copyright (c) 1988-2000 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)� So, how can I change it for working with SQL 2005?. It’s like I’m working with SQL 2005 interface but internally it works as SQL 2000. Can you help me please?

View 2 Replies View Related

How To Get The Output Parameter From An Internally Called Stored Procedure???

May 29, 2005

Hi all,i have a problem and couldnt find anything even close  to it. please help me, here is the description of what i m trying to accomplish:I have a trigger that is generating a column value and calling a stored procedure after the value is generated. And this stored procedure is setting this generated value as an output parameter. But my problem is:my asp.net page is only sending an insert parameter to the table with the trigger, trigger is running some code depending on the insert parameter and calling this other stored procedure internally. So basically i m not calling this last stored procedure that sets the output parameter within my web form. How can i get the output parameter in my webform? Everthing is working now, whenever an insert hits the table trigger runs and generates this value and called stored procedure sets it as an output parameter. I can get the output parameter with no problem in query analyzer, so the logic has no problem but i have no idea how this generated output parameter can be passed in my webform since its not initiated there.any help will greately be appreciated, i m sure asp.net and sql server 2000 is powerful and flexible enough to accomplish this but how??-shane

View 8 Replies View Related

Working With SQL 2005 Interface But Internally It Works As SQL 2000

Aug 27, 2007

Hi!

I have installed SQL 2000 and SQL 2005 in my computer. But none of 2005 feature is working. So someone told me that i had to check the version and when I cheked I realized I was working with SQL 2000:
€œMicrosoft SQL Server 2000 - 8.00.194 (Intel X86)
Aug 6 2000 00:57:48
Copyright (c) 1988-2000 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)€?

So, how can I change it for working with SQL 2005?. It€™s like I€™m working with SQL 2005 interface but internally it works as SQL 2000. Can you help me please?

View 1 Replies View Related

BUg In JDBC Driver 1.2 - Fails To Call Stored Procedures Which Use Ap_name() Internally.

Nov 9, 2007

Using the MSSQL JDBC 1.2 driver (Oct 2007 release), we don't seem to be able to call stored procedures which internally uses app_name() function to fill into database tables .


This driver fails to access such stored procedures in both SQL Server 2000 and SQL Server 2005 databases.
The previous 1.1 driver (2006), suceeds in both cases.

Here is a test case which demonstrates this problem.

create table ICS_ConsraintTest (PrimaryIdentifier varchar(64),
ServiceProvider varchar(64),
SecondaryID varchar(64),
SecondaryServiceProvider varchar(64),
Description varchar(64),
PanoramaObject varchar(64),
Operation int,
ScalingFactor int,
DisplayAs float,
FeedType int,
InputValue int,
OutputValue float,
salary float,
birthdate datetime,

CONSTRAINT SimpleTestConstraint CHECK((len(ltrim([PrimaryIdentifier])) > 0
and len(ltrim([ServiceProvider])) > 0
and len(ltrim([SecondaryID])) > 0
and len(ltrim([PanoramaObject])) > 0
and [salary] <> 0.0)))
Stored procedure id defined as follows:


CREATE PROCEDURE SP_ICS_TestWithConstraints1(@PrimaryIdentifier varchar(64),
@PrimaryServiceProvider varchar(64),
@ServiceProvider varchar(64),
@SecondaryID varchar(64),
@SecondaryServiceProvider varchar(64),
@Description varchar(64),
@PanoramaObject varchar(64),
@Operation int,
@ScalingFactor int,
@DisplayAs float,
@FeedType int,
@InputValue int,
@OutputValue float,
@salary float,
@birthdate datetime) AS
BEGIN

BEGIN TRANSACTION

BEGIN
/* Insert */
INSERT INTO ICS_ConsraintTest ( PrimaryIdentifier,
ServiceProvider,
SecondaryID,
SecondaryServiceProvider,
Description,
PanoramaObject,
Operation,
ScalingFactor,
DisplayAs,
FeedType,
InputValue,
OutputValue,
salary,
birthdate)

VALUES ( @PrimaryIdentifier,
@ServiceProvider,
app_name(),
@SecondaryServiceProvider,
@Description,
@PanoramaObject,
@Operation,
@ScalingFactor,
@DisplayAs,
@FeedType,
@InputValue,
@OutputValue,
@salary,
@birthdate)
END
COMMIT TRANSACTION

END
Check out the app_name() is passed as the SecondaryID which causes the failure.

View 6 Replies View Related

SQL 2012 :: Change Minimum Permissions To Allow Read Access To Change Tracking Functions

May 12, 2015

Trying to determine what the minimum permissions i can grant to a user so they can see the change tracking data

View 1 Replies View Related

Aspnet_regsql.exe And Generated SQL

Jun 21, 2006

Where is the sql generated by aspnet_regsql.exe saved?

View 2 Replies View Related

How To Get Generated Identity Value?

Oct 1, 2004

Hi,

How can I retrieve generated identity value after insert a row into table in case I can identify inserted row?

(the INSERT statement is dynamic constructed and queried from data access layer, not in stored procedure)

Thanks,

View 3 Replies View Related

How To Get Generated Identity Value?

Oct 3, 2004

Hi,

How can I retrieve generated identity value after insert a row into table in case I can identify inserted row?

(the INSERT statement is dynamic constructed and queried from data access layer, not in stored procedure)

Thanks,

View 1 Replies View Related

Auto-generated Key

Feb 7, 2007

Hello,

I've a problem with auto-generated key. In my parent table, some lines have been deleted. I would like to add new lines with the same content in order to restore my database, but I cannot decide on the id value which is an auto-generated key. Is there a solution to set an auto-generated key with a specific value ?

Thank you in advance,

regards,

mathmax

View 3 Replies View Related

SQL Generated Tables

Sep 27, 2007



Suppose I want to generate a table as below

No. Col1 Col2
1 100 Alan
2 110 Alan
3 120 Alan

In Column I there is a sequence of numbers from 1 to 3 with a step of 1
In Column 2 there is a sequence of numbers from 100 to 120 with a step of 2
In Column 3 there is a name that is repeated accross the whole column

Can I generate such a table with just a single SQL Statement . I don't see any reason why it should not be possible. We know the logic to generate all the numbers of every row. It would be possible using a while loop , but that is be tedious and I am looking for a better way.

One application I can think of is, Suppose I want to find out all deleted primary key ids from a table or say if I have a set
(1,2,3, 7,8,9) , and wish to know the missing numbers in the range 1 to 9. If an sql like above is possible I could use it in a left join to get me the desired output.

Could anyone tell me if it is possible and if not , why not ?

Thanks,
Alec

View 6 Replies View Related

SQL Query Generated.

May 2, 2008

Hi,

Is there any way to look at behind-the-scene SQL query that gets generated by SSRS engine to pull the data out of the data source (particularly SQL Server).

So far, I only know that you can see the query generated by semantic query engine by changing trace option in configuration file.

Thanks and Regards,
XL

View 2 Replies View Related

Report Is Being Generated

Aug 28, 2007

Hi
I have a windows application. I am using following code right after setting the LocalReport ReportPath. Report rendering is too slow if use following line of code and Report viewer does not show spiny and the text that says €œReport is being generated.€?

Me.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
Me.ReportViewer1.ZoomMode = ZoomMode.Percent
Me.ReportViewer1.ZoomPercent = 80

Please advise how can make it fast and show spiny.

Thanks in advance.

View 8 Replies View Related

Report Is Being Generated But Never Does...

Aug 17, 2006

I have created a report and deployed it successfully to a seperate machine with SSRS on. Both my dev machine and the SSRS machine are in the same workgroup. I can then Browse to the Report Manager though IE and click & run the report (The connection is using integrated security). The report requires a single parameter to be entered which once done works successfully. The report has a single table, an inbedded image and a few static fields in the report header.

If I however add a report viewer control to an aspx test form all is not well. As soon as the page opens I am prompted to enter the parameter which is good news as it shows there has been some communication with the SSRS metabase. I then click the view report button. Using Profiler I have proved that the report Stored Proc. is running with the correct parameter value. The report viewer however seems to hang and only displays "Report is being generated" without displaying the results. It does this even with a timeout set of 1000ms.

I don't think this is a security issue as both the Report Manager works and the test form prompts me for the parameter and effectively runs the report SP. I can only assume it is a problem with returning the report to the browser.

Does anyone have any insight?

Regards

Anthony Kay

View 3 Replies View Related

Id Getting Generated Differently

Apr 13, 2006

Hi,

I created a PDA application with a database, which has a table with a uniqueidentifier field and primarykey.

While doing the bulk insert from dataset into sql mobile database, It is inserting the record but it is not inserting the id which was entered into the sql server 2005 database, instead the id by creating a new id and the code is as below.

conAdap = new SqlCeDataAdapter(strQuery, conSqlceConnection);

SqlCeCommandBuilder cmdBuilder = new SqlCeCommandBuilder(conAdap);

conAdap.Fill(dsData);

int r =conAdap.Update(dsData);

Please help me.

Thank you,

Prashant

View 1 Replies View Related

My Report Can't Be Generated

Jan 16, 2008



Hi,

I have a report which doesn't work. It has a datatset based on a store procedure. The store-procedure take 10 to 50 second to execute, depending on the parameters.

But, I can't never see my report as i wait more than 10 minutes and it's never generated.

So, I have think that maybe it could be because of the matrix inside the report, so I have try to create another report which have the same dataset but with nothing inside, just a textbox, and it doesn't work too !!
So now, i'm very disapointed and I don't know what to do !
Someone can help me please ? It's very important.

Thank you.

View 2 Replies View Related

TableAdapter Class Not Generated

Aug 2, 2006

I created a new DataSet object using the
wizard and had no probs, it's very straightforward.  I created a
GetProducts() method and also added a GetProductCount() method.  I
read somewhere that when the DataSet is saved, it will generate the
TableAdapter classes and store them in the project nested under the
DataSet object.  This isn't happening, the files aren't there and
yes I'm displaying all files.  There *is* however the TableAdapter
class but it's in not in the project, it's a temporary file w/ the
following path:
   
C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET
Fileswebsitef38f8b5500014aeSources_App_Codepw_products.xsd.72cecc2a.cs.

I saved the DataSet several times, compiled the entire solution and
even closed the solution yet this temporary file isn't getting saved
where it should be.  Does anyone have any ideas abt this? 
I'm eager to start developing my DAL and def want to use these
TableAdapter classes.

Thx in advance,
-Pete

View 2 Replies View Related

Generated Sprocs Of VS2005

Oct 24, 2006

Can someone explain the generated sprocs of VS2005 if one column can be nullableDependentOfSeqID = @Original_DependentOfSeqID OR ((@IsNull_DependentOfSeqID = 1) AND (DependentOfSeqID IS NULL))In VS2003 the generated sprocs would beDependentOfSeqID = @Original_DependentOfSeqID OR ((@Original_DependentOfSeqID IS NULL) AND (DependentOfSeqID IS NULL))Which is the best? 

View 1 Replies View Related

SQL Exception Generated By Server

Nov 11, 2006

HI all,
if this issue has been solved, please provide me the post, or I've put this issue in a wrong category please let me know.
The following is my code:
DateTime dtBFWNow = DateTime.Today;
String dtBFW_range1 = dtBFWNow.AddDays(-7).ToShortDateString();
String dtBFW_range2 = dtBFWNow.AddDays(3).ToShortDateString();
SqlDataSource1.SelectCommand = "SELECT * FROM [MORTGAGE] WHERE ([BringForwardDate] is not null) and ([BringForwardDate]>= '" + dtBFW_range1 + "' and [BringForwardDate] <= '" + dtBFW_range2 + "')";
lblHeader.Text = "Bring Forward Reminders Due From '" + dtBFW_range1 + "' To '" + dtBFW_range2 + "'";
lblHeader.ForeColor = System.Drawing.Color.FromName("#000000");
GridView1.DataBind();
When I compiled, the following exception occurred:
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
and the exception points right at the line: GridView1.DataBind() 
I use the webhost4life as my server provider.  My codes run fine with the server.  I mean I uploaded my program to the server, set up and run the program online, everything is fine. 
But on my PC it gives me the above exception.  I can't compile my code.  There must be some sort of setting somewhere in my PC that can't handle the exception.
Please help.
Regards.
Joey.
 

View 2 Replies View Related







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