Last Query Statement Fired Into The MSSQL Engine
Jan 8, 2007
Hi,
How can you get the Query Statement of the last executed SQL command.
I am not quite sure but I do remember coming across such a command ( maybe an undocumented one).
Thanks for your help and pointers.
My Best wishes for the new year to all the folks in the forum. Wishing you greater days ahead.
Warm Regards,
Ranjit S Hans.
---------------------------------------------------------------------
Everywhere is a walking distance if you have the time - Steven Wright
View 4 Replies
ADVERTISEMENT
Jul 10, 2007
Hello all,
I'm trying to cath content of PRINT statements through InfoMessage event. I have subscribed on InfoMessage event through ConnectionEventsVt interface. The problem that event fired only once for statement. For example i have following T-SQL script:
Code Snippet
PRINT 'Message1'
PRINT 'Message2'
GO
PRINT 'Message3'
PRINT 'Message4'
GO
When i execute this script InfoMessage event fired twice. First time Error object Description property contains "Message1" text. Second time it contains "Message3" text.
What i'm doing wrong?
Server: MS SQL Sever 2005
OS: Windows XP SP2
IDE: Delphi 7
View 1 Replies
View Related
Apr 19, 2006
By Database is heavily used , we use Transaction log backups ever 10 minuts, now someone fired a wrong query , that updated a particular table , the DB is still in use, there are some users working on it , I cant get the DB offline , what can I do to correct the mistake , please advice.
View 7 Replies
View Related
Jul 17, 2007
Hi all,
I am investigating using Query Notifications - a great addition BTW. I have built a test app - loosely based on MSDN example - and am running against a SQL Express 2005 server. I have the following problem:
I have start/stop buttons to enable change checking, and a hardcode query that I am using for testing. If I stop and restart I now recieve duplicate notifcations, a single change causing the OnChange event to fires twice with two different ids Repeat this and the event will fires 3 times for each change and so on.
This only happens with a running app, if I restart the app I only get a single notification so I assume I have missed a step in stopping query notifcations or reinitialisation. I have include code below:
private bool Start()
{
try
{
// Remove any existing dependency connection, then create a new one.
SqlDependency.Stop(_currentConnectionString);
if (SqlDependency.Start(_currentConnectionString))
{
if (connection == null)
{
connection = new SqlConnection(_currentConnectionString);
}
if (command == null)
{
command = new SqlCommand(_sqlQueryString, connection);
}
return (true);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
return false;
}
private void Stop()
{
SqlDependency.Stop(_currentConnectionString);
if (command != null)
{
command.Notification = null;
command = null;
}
if (connection != null)
{
connection.Close();
connection = null;
}
}
private void GetDataSnapshot()
{
// Empty the dataset so that there is only
// one batch of data displayed.
dataToWatch.Clear();
// Make sure the command object does not already have
// a notification object associated with it.
command.Notification = null;
// Create and bind the SqlDependency object
// to the command object.
SqlDependency dependency = new SqlDependency(command);
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
adapter.Fill(dataToWatch, tableName);
}
}
private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
{
// This event will occur on a thread pool thread.
// Updating the UI from a worker thread is not permitted.
// The following code checks to see if it is safe to
// update the UI.
ISynchronizeInvoke i = (ISynchronizeInvoke)this;
// If InvokeRequired returns True, the code
// is executing on a worker thread.
if (i.InvokeRequired)
{
// Create a delegate to perform the thread switch.
OnChangeEventHandler tempDelegate = new OnChangeEventHandler(dependency_OnChange);
object[] args = { sender, e };
// Marshal the data from the worker thread
// to the UI thread.
i.BeginInvoke(tempDelegate, args);
return;
}
// Remove the handler, since it is only good
// for a single notification.
SqlDependency dependency = (SqlDependency)sender;
dependency.OnChange -= dependency_OnChange;
// At this point, the code is executing on the
// UI thread, so it is safe to update the UI.
++changeCount;
lblStatus.Text = String.Format(statusMessage, changeCount);
// Add information from the event arguments to the list box
// for debugging purposes only.
//lbChanges.Items.Clear();
lbChanges.Items.Add("+++++++++++++++++");
lbChanges.Items.Add("Id: " + dependency.Id);
lbChanges.Items.Add("Info: " + e.Info.ToString());
lbChanges.Items.Add("Source: " + e.Source.ToString());
lbChanges.Items.Add("Type: " + e.Type.ToString());
// Reload the dataset that is bound to the grid.
if (e.Info != SqlNotificationInfo.Error)
this.GetDataSnapshot();
}
Thanks, Nick
View 3 Replies
View Related
Nov 5, 2015
I've have a need with SQL Server 2005 (so I've no MERGE statement), I have to merge 2 tables, the target table has 10 fields, the first 4 are the clustered index and primary key, the source table has the same fields and index.Since I can't use the MERGE statement (I'm in SQL 2005) I have to make a double step operation, and INSERT and an UPDATE, I can't figure how to design the WHERE condition for the insert statement.
View 2 Replies
View Related
Nov 6, 2007
I have a MS 2003 server where the os adminstrator has loaded the tools for a MSSQL 2005 but not the instance.
I went in to add the component via the Add & remove programs and selected Microsoft SQL Server 2005.
Selected change
I entered the path for the cd but only get the setup.exe for the components; sql mangement studio....
what is the path to install the Database Engine component.... inorder to load a new default instance?
osbornet
View 4 Replies
View Related
Feb 20, 2007
Just downloaded and installed mssql 2005 sp2 on one of our servers
All components upgrade apart from the database engine. After the first upgrade i rebooted then tried to update the db engine again it failed for a second time.
Below is the error from mssql setup, any help would be nice!
Event Type: Error
Event Source: MsiInstaller
Event Category: None
Event ID: 1023
Date: 2/20/2007
Time: 12:08:11 AM
User: DNETWORKdadmin
Computer: SGC
Description:
Product: Microsoft SQL Server 2005 - Update 'Service Pack 2 for SQL Server Database Services 2005 ENU (KB921896)' could not be installed. Error code 1603. Additional information is available in the log file C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGHotfixSQL9_Hotfix_KB921896_sqlrun_sql.msp.log.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 7b 45 42 37 36 42 32 31 {EB76B21
0008: 38 2d 38 46 43 35 2d 34 8-8FC5-4
0010: 31 44 46 2d 39 46 31 46 1DF-9F1F
0018: 2d 37 46 46 33 45 30 34 -7FF3E04
0020: 34 38 33 38 33 7d 20 7b 48383} {
0028: 30 34 41 44 42 33 46 44 04ADB3FD
0030: 2d 42 32 38 36 2d 34 39 -B286-49
0038: 41 46 2d 38 35 34 45 2d AF-854E-
0040: 45 44 44 33 38 42 36 44 EDD38B6D
0048: 45 36 44 37 7d 20 31 36 E6D7} 16
0050: 30 33 03
MSSQL Setup log http://www.dwebs.ltd.uk/mssqlinstall.txt
Its a rather large file!
View 6 Replies
View Related
May 13, 2008
Hi,
Mysql database provides a storage engine called "MERGE".A "MERGE" table is a collection of identical tables that can be used as one.(Identical meaning same column name,column width, column order etc.) .
The advantage is you can split a really huge table like LOG tables, STATS tables into seperate smaller tables but would still be able to make queries on them like a single table. More details, can be got from here:
http://dev.mysql.com/doc/refman/4.1/en/merge-storage-engine.html
My question is that do we have an equivalent of MYSQL "MERGE" in MSSQL ????
Thanks,
:)
View 2 Replies
View Related
Nov 4, 2005
I'm converting to mssql. I've been using the following statement in a php query with mysql.
$result = mysql_query ("SELECT * FROM inks i, sample s, customer c, press pr WHERE s.JobNum like '$JobNum%' and c.CustName like '$CustName%' and pr.PressID like '$PressID%' and s.InkID like'$InkID%' and c.CustNum=s.CustNum and pr.PressID=s.PressID and i.InkID=s.InkID and s.Bindery like'%$Bindery%'");
This allowed me to select a press and/or certain paper and/or certain ink, etc. Allowed me to select any combination needed to find.
Now when I use this statement I don't get any results. I have the following which works if I select items in all categories, but that isn't always possible. I need a wildcard selection if we don't know or don't care what press it was run on or what paper was run on a press or what ink was used to print, etc
$result = mssql_query ("SELECT * FROM text t, cover cv, sample s, customer c, press p WHERE (s.PressID like '$PressID' and p.PressID = s.PressID and c.CustNum=s.CustNum and t.TextPaperID=s.PaperTextID and cv.CoverPaperID=s.PaperCoverID) and (s.PaperTextID = '$TextPaperID' and t.TextPaperID=s.PaperTextID and p.PressID = s.PressID and c.CustNum=s.CustNum and cv.CoverPaperID=s.PaperCoverID) and (s.PaperCoverID = '$CoverPaperID' and t.CoverPaperID=s.PaperCoverID and p.PressID = s.PressID and c.CustNum=s.CustNum and cv.TextPaperID=s.PaperTextID) order by CustName");
I'm lost
Thanks For the help.
View 3 Replies
View Related
Aug 3, 2015
Could a simple update statement on a user database ever caused space usage in tempdb? Assuming the update statement fires no triggers and not using any temp tables?
IE:
User DatabaseA
Update TableX
Set col1 = X
Reason I ask is tempdb filled up and the only thing I could see running at that time was the update statement.
View 8 Replies
View Related
Jul 10, 2001
Hi,
I have an Access frontend and an SQL Server backend. I use a Query (in Access frontend) to insert in two tables simultaneously. I have a trigger in one of the involved table which update the foreign key in another involved table.
I've built an SQL View with exacly!!! the same syntax as my Query in Access.
And when I insert a new entry through the SQL View the trigger fires(the foreign key is updated), but when I insert through my Access Query the trigger doesn't fires (the foreign key is not updated).
Any idea ?
Thanks in advance
View 1 Replies
View Related
Sep 9, 2014
I have TSQL query using UNION ALL. First subset returns 92 rows, second subset return 0 (ZERO) rows. Now if I execute them separately they execute subsecond. If I put UNION ALL between them then it hangs forever exactly on 88s row.
I understand I need to provide execution plans, actual queries etc but before going into all this details, why on earth even in theory UNION ALL with empty result will result in a hang of the first subset?
Based on estimated execution plan 2 subqueries are performed in parallel and then CONCATENTION is being used which shall result with just first subset immediately displayed in result.
Estimated execution plan attached, I can not get actual execution plan because query never completes.
View 9 Replies
View Related
Oct 8, 2015
I've some huge table (over 100GB each), these table contain column of NTEXT, IMAGE. Application team needs to change these data types to VARBINARY(MAX), I've tested the modification in our lab and I noticed that the operation has been almost immediate so, I think that DB Engnine has not converted the existing data in the column but it has simply changed the definition of the column.
Or maybe NTEXT and IMAGE can be transparently converted into VARBINARY(MAX)?
Anyway, I want to be sure that the modified table is "coherent" I don't want that at a given point SQL Server tells me that some data is not readable.
View 3 Replies
View Related
Dec 3, 2013
I get this error when inserting data..The INSERT statement conflicted with the FOREIGN KEY constraint FK_Participant_ Log_BiometricInstance_ Participant_ Activities". The conflict occurred in database "ProvantCustomerPortal", table "dbo.Activities", column 'Id'.The statement has been terminated.
My query looks like this :
insert into [dbo].[Participant_BiometricInstance](ParticipantId, ActivityId, ProviderTypeId, Fasting, ExternalSystemId, ResultsDate, ModifiedBy, ModifiedDate)
select participantID,'','','',NULL,getdate(),NULL,getdate() from [dbo].[Participant_Profile]
[code]....
View 11 Replies
View Related
Sep 25, 2006
Hi everyone,
I was wondering when events inside IDTSComponentEvents interface are called when you throw a SSIS package? I've got a private class which implements IDTSEvents and along with that got another one that implements the IDTSComponentEvents. I see how neither of them are fired when I debug the code by using F11, and I don't know what is it for.
Let me know your comments or come back to me if you need further details on that.
Thanks in advance,
View 4 Replies
View Related
Nov 9, 2015
Primary platofrm: Sql12k, 7.0 Ultimate Pro OS
I'm launching the aforementioned statement from one MASTER session windows and I get this message, I am stuck, I though ROLLBACK INMEDIATE go throught any already session open.
Msg 5064, Level 16, State 1, Line 1
Changes to the state or options of database 'GFSYSTEM' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
View 4 Replies
View Related
Oct 6, 2015
SQL Server 2012 Performance Dashboard Main advices me this:
Since the application is from a vendor and I have no control over its code, how can improve this sitation?
View 3 Replies
View Related
Mar 21, 2007
Is it possible to only handle the outter-most event? For example, I have an email that goes out in response to OnPreExecute and OnPostExecute, but I only want it to go out once, instead of for every tasks/object.
Thanks,
Rick
View 1 Replies
View Related
May 23, 2002
Hi,
We have an asp web aplication using COM on a SQL Server 2000 database. The application uses COM to perform the database access. On altering data, the code checks the @@rowcount to see if the intented insert or update was succesfull - this is done on changes in various colums in various locations in the code.
Now we need to add a trigger to update changed data into other tables. This is because we start migrating to a different data structure - while keeping most of the original code intact.
The problem is now, that the trigger beeing fired erases the @@rowcount. I can imagine others to have experienced the same problem. So, the big question is here:
Is there a solition/workaround to keep the @@rowcount on update/insert/deletes on a table evn if a trigger fires?
Thank you,
Marco van Schagen,
Crexx, the Netherlands
View 1 Replies
View Related
Apr 16, 2014
Our company purchased a app. Is there any way to find out which store procedures were fired once a button was clicked?
View 3 Replies
View Related
Mar 4, 2008
Hi,
I've created the following trigger:
CREATE TRIGGER myTriggerServer
ON ALL SERVER
FOR CREATE_LOGIN, ALTER_LOGIN, DROP_LOGIN
AS
BEGIN
EXEC myDatabase.dbo.myProcedure
END
The trigger is NOT fired (and procedure not executed) when I create a new login or alter an existing login.
Only Drop Login fires the trigger.
Please tell if it's a problem with SQL Server 2005 or am I making some mistake here?
-Anshul
View 4 Replies
View Related
Sep 12, 2007
if service broker is not an option, how can the trigger and sp(s) called by our trigger act asynchronously to the event that fired the trigger in the first place. We are more concerned with the original event being committed than the actions that follow via the trigger.
View 4 Replies
View Related
Jan 17, 2007
Greeting.
I use OdbcConnection inside clr procedure, for getting data. If I use simple EXEC dbo.clr_proc - all is OK. If I use INSERT...EXEC I recive error message: Distributed transaction enlistment failed.
I set MSDTC security options for No Authentification and Allow inbound and Allow outbound, but it's no use.
Have this problem solution? May be, I must use another method to get my data?
P.S. Linked Servers and OPENQUERY is not applicable. Sybase not describe columns in stored proc result set and one stored proc may return different result set by params.
P.S.S. Sorry for bad english.
View 1 Replies
View Related
Jul 12, 2007
Hi,
Is there any way that I can know the count of queries and queries fired to the database after running a ssis package?
can any one help me out?
Thanks in advance.
View 3 Replies
View Related
Jan 4, 2007
Can anyone tell me why I am getting this error when I try to view my report:
Query Engine Error: '21000:[Microsoft][ODBC SQL Server Driver][SQL Sever] Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <=,>,>= or when the subquery is used as an
View 4 Replies
View Related
Dec 9, 2004
Having problem completing this query. I have a list of items. Some items need to be grouped by a list, some by a range. I was thinking of useing two tables, one for the items, and one for the groups. The groups would have something like groupid, title, listnumbers, rangelow, and rangehigh. The tables are in sql database. For example:
The list of items numbers are 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20. In the group table, it would be listed like this:
G1, Group1, 1,,
G1, Group1, 6,,
G2, Group2, ,2,5
G3, Group3,6,18,20
G3, Group3,7,15,17
G3, Group3,8,14,16
G3, Group3,9,11,13
In this example, Group1 is a list, group2 is a range, and group3 is a list of ranges. I can make a query that pulls all the items just in the groups:
SELECT ECC_ITEMS.NBR, Group.Group_Name, Group.Title, ECC_ITEMS.DESCR, ECC_ITEMS.REG_PRC
FROM Group, ECC_ITEMS
WHERE ECC_ITEMS.NBR Between Group.RangeLow And Group.RangeHigh Or ECC_ITEMS.NBR=Group.GroupItems
Now, I am not sure how to put the rest of the items (the ones that aren't in a group) in that query. I was thinking on making a union and the second query being a unmatched query. Not sure how to make it were that query is "unmatched" with a table in the same query. And ideas on how to make the second part of the union query?
View 3 Replies
View Related
Aug 13, 2007
How SQL Query/ Stored procedure are being executed by SQL Server Engine ?
View 1 Replies
View Related
May 19, 2006
After making several hundred queries against a SQL CE 2.0 database (through NetCF/ADO.NET), I begin getting a SqlCeException: "Not enough storage is available to complete this operation."
Microsoft speaks to this situation in the following hotfix:
http://support.microsoft.com/?kbid=827837
When I contacted them to receive the hotfixed ssce20.dll, they described the problem as SqlCeDataReader and SqlCeDataAdapter not releasing their memory resources after they went out of scope. In addition to using the hotfixed binary, they also advised me to call SqlCeEngine.Dispose() after every query to force SQL CE to release resources, as shown in the "finally" block of the code below.
I have a couple of questions about this:
(1)
Will this cause a lot of performance overhead for me, especially if my application makes frequent queries using the following code?
(2)
Can a cache an instance of SqlCeEngine and call Dispose() on that cached instance repeatedly, so I can avoid having to instantiate a new SqlCeEngine each time?
SqlCeConnection conn = null;
try
{
conn = new SqlCeConnection(connectionString);
dbCmd.Connection = conn;
dbCmd.Connection.Open();
dbCmd.ExecuteReader(CommandBehavior.CloseConnection);
<use the reader>
}
finally
{
dbCmd.Connection.Close();
// Add the following code to release resources?
SqlCeEngine engine = new SqlCeEngine(connectionString);
engine.Dispose();
}
View 1 Replies
View Related
Aug 26, 2015
I have a the following query which takes long time
DECLARE @ACCOUNTS TABLE(ACCOUNT_ID INT)
INSERT INTO @ACCOUNTS
SELECT ACCOUNT_ID FROM ACCOUNT
WHERE A_DESCR in ('AA', 'BB', 'CC', 'DD', 'EE', 'FF', 'GG')
I used the following key words: sql server query tuning in operator
View 2 Replies
View Related
May 6, 2015
Is there has any SQL query to check running out of "min memory per query SQL Server"(default value is 1024KB)?
View 2 Replies
View Related
Aug 18, 2015
I have a query that is using up the whole TempDB (50GB) and still failing because the disk runs out of space.
The script has SELECT FROM SELECT FROM SELECT etc. and in each select it also seems to have joins.
I can also see a few UNION and UNION ALLs.
Is this normal for one query to use up that much space?
If I wanted to make this better where would I start?
View 9 Replies
View Related
Jan 18, 2008
in mysql, we can have
select * from test where date like '%-02-01'
all result that ends with -02-01 will be displayed.
however, if i want to do it in ms sql, may i know what's the syntax for this select....like ?
Thanks.
View 1 Replies
View Related
May 30, 2008
Code:
Select id from tbl_account in Game_User DB
id is binary data
USE Billing
INSERT INTO tblUser (userId,cpId,userTypeId,userStatusId,gameServiceId) VALUES ('test','1','1','9','6') where userId = id from tbl_account
and
INSERT INTO tblUserInfo (userNumber,userId,cpId,userTypeId,userStatusId,gameServiceId) VALUES ('123','test','1','1','9','6') where userNumber = userNumber and userId = userId from tblUser
Im new when it comes to making SQL queries, so i need help badly.
Basically what i need the query to do is call from a DB "User" id where the id is in Binary data. from that i need it to insert into 2 other tables in the Billing DB.
the UserId needs to be the same in all areas, and when it inserts into tblUserInfo it has to pull from userNumber from tblUser after the rows are entered so that the userNumber in tblUser and tblUserInfo are the same.
Hopefully you can help. if any further information is needed please just ask and ill try to give as much as i know.
Thanks
David
View 2 Replies
View Related