Friday, March 23, 2012
How to get the last Query executed?
Hello, i have a trigger and i want to know the query that raised it, or want to retrieve the last executed query by the server. I think it's a hard question but i know that someone can help me... Thanks
Fire up SQL Profiler and run a trace with the filters configured to limit it to the table in question (object).|||if object_id('dbo.test') is not null
drop table dbo.test
go
create table dbo.test (f1 int null)
go
create trigger dbo.trgIUD_test on dbo.test for insert, update, delete as
dbcc inputbuffer (@.@.spid)
go
insert dbo.test values (1);
go
drop table dbo.test
go|||Originally posted by Steve Duncan
Fire up SQL Profiler and run a trace with the filters configured to limit it to the table in question (object).
Hey, i didn't know that exists, thank you for your help!, has very very use full!
How to get the index of each row from a SELECT query in SQL ?
I am making as SELECT query to fill a repeater, and I need to retrieve the index of each line of the query.
ie, I want to get a dataset like :
"0", "dataCol1", "dataCol2" for the first line
"1", "dataCol1", "dataCol2" for the second line
"2", "dataCol1", "dataCol2" for the third line
etc.
Anyone knows if there is a sql statement that does it ?
Thanks
Johanncheck this|||You can also create a temp table with an int identity column, insert the first table into the temp, and return it.
how to get the highest row from the bunch of rows
rows like...my table is:
name year
a 2008
a 2006
b 2007
b 2006
b 2005
c 2007
c 2004
I just need the latest year for all the names like:
name year
a 2008
b 2007
c 2007
THANKS..."sql_learner" <mailfrd@.gmail.com> wrote in message
news:eafce7c0-7c49-415e-b410-336593650ce2@.s8g2000prg.googlegroups.com...
> hi...i just want to retrieve the highest row from the collection of
> rows like...my table is:
> name year
> a 2008
> a 2006
> b 2007
> b 2006
> b 2005
> c 2007
> c 2004
> I just need the latest year for all the names like:
> name year
> a 2008
> b 2007
> c 2007
> THANKS...
SELECT name, MAX(year) year
FROM tbl
GROUP BY name;
--
David Portas|||sql_learner wrote:
> hi...i just want to retrieve the highest row from the collection of
> rows like...my table is:
> name year
> a 2008
> a 2006
> b 2007
> b 2006
> b 2005
> c 2007
> c 2004
> I just need the latest year for all the names like:
> name year
> a 2008
> b 2007
> c 2007
> THANKS...
SELECT name,MAX(year)
FROM tablename
GROUP BY name
... p
--
Posted via a free Usenet account from http://www.teranews.com
how to get the duplicate file in ssis
Hi There,
Use this query to get the duplicate records from a table, if you are using flat file as a source, load it to the database table and use this query:
select coulmn a from <tablename> where column a in (select column a from <tablename> group by column a having count(*) > 1). This query will give you the list of records which is duplicate. Later you can add an excel destination to load these duplicate records.
Regards,
Raju
|||Hi
thanks for the reply, It work nice, somehow it disappoint me a bit (not on your answer), cause i thought i won't use the query anymore to disect the data and I thought ssis has tool for this. Anyway thanks!!!
Jagapathi Raju wrote:
Hi There,
Use this query to get the duplicate records from a table, if you are using flat file as a source, load it to the database table and use this query:
select coulmn a from <tablename> where column a in (select column a from <tablename> group by column a having count(*) > 1). This query will give you the list of records which is duplicate. Later you can add an excel destination to load these duplicate records.
Regards,
Raju
Wednesday, March 7, 2012
How to get output of sql command in columns
I am working with Informix db in Digital Unix.
When I try to give any select commands and try to retrieve more than 5 columns in the same sql command, the output comes in rows instead of columns.
Is there a way to force it to come in columns?
i just use a simple format,
select column1 ,column2 ,column3 ,column4 ,column5 from tableyou should be getting 5 columns per record in the DB
column1 ,column2 ,column3 ,column4 ,column5
column1 ,column2 ,column3 ,column4 ,column5
column1 ,column2 ,column3 ,column4 ,column5
column1 ,column2 ,column3 ,column4 ,column5
column1 ,column2 ,column3 ,column4 ,column5
how do you want the layout and why?
Friday, February 24, 2012
How to get list of backup log files from msdb of standby server?
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
Tram
Msdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegr oups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>
How to get list of backup log files from msdb of standby server?
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
TramMsdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegroups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>
How to get list of backup log files from msdb of standby server?
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
TramMsdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
--
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegroups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>
How to get list of all Sql servers on network
Is there any function/API in vb to retrieve all the sql servers that are avaiable on a network? Basically, i wanted to implement this facility in my application where users can select a server from list of all avaiable servers on LAN.
Thanks!
Asif.Net, Im having trouble with a couple of the TYPES that are used in the functions.
Have you got this figured out in .NET yet?
Please let me know if you have a resolution.
Thanks,
Malcolm Phillips
Malcolm.Phillps@.prgx.com|||If you get GFI lanscan you'll find there's a script there that enumerates SQL Servers on the network. Its basically VB script but I don;'t have it here at home.
To do it in asp.net I think you'd need to import the SQLDMO namespace|||How do I import the SQLDMO namespace? Please|||You add the Microsoft SQLDMO Object Library as a (COM) Reference to your project, then you add
<%@. Import Namespace="SQLDMO"%>to your ASP.NET page.
Terri|||Take a look at http://www.extremeexperts.com/sql/faq/SQLDMO-ListServers.aspx for an example ... This works in VB also ...|||Dim mDMOApp As New SQLDMO.Application Dim mNames As SQLDMO.NameList Dim t As Integer mDMOApp = New SQLDMO.Application mNames = mDMOApp.ListAvailableSQLServers() lstServers.Items.Clear() For t = 1 To mNames.Count lstServers.Items.Add(mNames.Item(t)) Next
Sunday, February 19, 2012
How to get generated identity value?
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,In the same batch, you can use @.@.identity (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_globals_50u1.asp) or scope_identity() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sa-ses_6n8p.asp). Once you allow the batch to end, it gets a lot trickier to get the identity value back.
-PatP
How to get execution progress ?
executed programatically.
What I am trying to do, is to launch ssis package on server
and send the progress ("percent complete") to some remote client in order to display it
in progress bar.
I want that ,while ssis package executes, it will raise some event every time the progress changes.
Implement an IDTSEvents interface and pass it to the Execute method.
This Books Online page has more details:
http://technet.microsoft.com/en-us/library/ms135967.aspx
|||I've tried to do that, but without any success.namespace SSIS_EXEC_SERVER
{
class ExecuteSSIS : IDTSEvents, IHandler
public ExecuteSSIS(I)
{
MyRemotableObjects.Cache.Attach(this);
}
public String fire(string location)
{
Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
package = app.LoadPackage(location, this);
package.DesignEvents = this;
Microsoft.SqlServer.Dts.Runtime.DTSExecResult result= package.Execute();
}
IDTSEvents Members
.
.
.
.
When I preform package.Execute() the ExecuteSSIS class does not recieve any events.
There is OnProgress method in IDTSEvents and I asumed that it will be informed by the package (there
is PercentComplete paramether in the method).
But still no success...