Showing posts with label execute. Show all posts
Showing posts with label execute. Show all posts

Sunday, March 11, 2012

a SqlDataSource can execute two InsertCommand?

hi everyone

i have a SqlDataSource
and i want execute two T-Sql (two InsertCommand)
but not success
How did i do this?

Thanks

1 Protected Sub SqlDataSource1_Inserted(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)Handles SqlDataSource1.Inserted
2 Dim SDSTempAs SqlDataSource =Nothing
3 Try
4 SDSTemp =New SqlDataSource(CnStr,"")
5 SDSTemp.InsertCommandType = SqlDataSourceCommandType.Text
6 SDSTemp.InsertCommand ="INSERT INTO Table1 (id,t1,t2) VALUES (@.id,@.t1,@.t2)"
7 Dim idAs String = e.Command.Parameters("@.id").Value.ToString
8 SDSTemp.InsertParameters.Add("id", id)
9 SDSTemp.InsertParameters.Add("t1",CType(FormView1.FindControl("TextBox1"), TextBox).Text)
10 SDSTemp.InsertParameters.Add("t2",CType(FormView1.FindControl("TextBox2"), TextBox).Text)
11 SDSTemp.Insert()
12
13 SDSTemp.InsertCommand ="INSERT INTO Table2 (id) VALUES (@.id)"
14
15 SDSTemp.InsertParameters.Add("id", id)
16
17 SDSTemp.Insert()
18 Catch exAs Exception
19 Message.Text = ex.Message.ToString
20 End Try
21 End Sub
22

you can use the ItemCommand Event and place your code in there. Here is a reference you can use:http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.itemcommand.aspx

The following link shows an quick example I made to help ya out some more also:http://forums.asp.net/thread/1692239.aspx

Hope this helps.

A SQL Server and Access Question

How do you execute a SQL Server stored procedure or query from an Access mdb?
Thanks.
VBA
http://sqlservercode.blogspot.com/
"John Lane" wrote:

> How do you execute a SQL Server stored procedure or query from an Access mdb?
> Thanks.
|||By executing a pass-through query if the results are intended to be
read-only, or querying a linked table if you need the results to be
updateable. You can use DAO via VBA for this, or simply set a form or
report to the pass-through query. If you have follow-up questions,
post on microsoft.public.access.odbcclientserver -- that's where the
Access experts hang out, and you'll likely get a wider range of
responses than posting here.
--Mary
On Thu, 13 Oct 2005 13:45:08 -0700, SQL
<SQL@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>VBA
>http://sqlservercode.blogspot.com/
>"John Lane" wrote:

A small question

Hi,
I want to give execute persmission to a user called "user1" on xp_cmdshell.
How do i do this through an SQL script?
Thanks in advance.
/AQI figured it out myself... Thanks :-)
"MAQ" <dingdongdang@.msn.com> wrote in message
news:euLv$7TKFHA.3336@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I want to give execute persmission to a user called "user1" on
> xp_cmdshell.
> How do i do this through an SQL script?
> Thanks in advance.
>
> /AQ
>

Thursday, March 8, 2012

A simple loop

Hello
Was wondering if you guys could show me how to do a simple loop, Im trying
to execute a sp and pass the parameter CustomerID as parameter from the
select im looping through
/LasseLook for cursors in the BOL, you can also use a template from the QA, choose
Edit --> Add Template --> Using Cursor (then one of the templates)
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Lasse Edsvik" <lasse@.nospam.com> schrieb im Newsbeitrag
news:%234%23YbMQYFHA.1240@.TK2MSFTNGP14.phx.gbl...
> Hello
> Was wondering if you guys could show me how to do a simple loop, Im trying
> to execute a sp and pass the parameter CustomerID as parameter from the
> select im looping through
> /Lasse
>|||Instead of thinking about loops, look for a set-based solution first.
Loops aren't generally the best way to accomplish data manipulation
tasks.
The only loop construct in TSQL is the WHILE BEGIN ... END loop.
David Portas
SQL Server MVP
--|||http://www.extremeexperts.com/SQL/A...TSQLResult.aspx
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
"Lasse Edsvik" <lasse@.nospam.com> wrote in message
news:%234%23YbMQYFHA.1240@.TK2MSFTNGP14.phx.gbl...
> Hello
> Was wondering if you guys could show me how to do a simple loop, Im trying
> to execute a sp and pass the parameter CustomerID as parameter from the
> select im looping through
> /Lasse
>

Friday, February 24, 2012

A Question About Detecting ANSI_WARNINGS Warnings

Hi,

I have a question about ANSI_WARNINGS and how to detect them. If I execute the following query in Query Analyzer:

SET ANSI_WARNINGS ON
SELECT SUM(pubs..discounts.lowqty) FROM pubs..discounts

I see the warning, as expected:

----
100

(1 row(s) affected)

Warning: Null value is eliminated by an aggregate or other SET
operation.

Is there a place on the server (or, client) where this is logged? (The assumption should be that users won't be using Query Analyzer to execute SQL like this, so, of course, they wouldn't see the warning text.)

As for the OLE DB code, the HRESULT from executing this SQL is 0 (S_OK). Is there any programmatic way of detecting this warning so that I may log to a file, etc.?

TIAI hope u need to specify ANSI_Warnings OFF

:)

A QUERY THAT RUN ON DB2 THAT HAVE MORE PERFORMANCE THAN SQL SERVER 2000

The execution time for this query on DB2 v8.0 DBMS one second but I execute it on SQL SERVER 2000 is around 55 second
so how i can incease the performance for SQL server
SELECT ACC_KEY1,ACC_STATUS_LAST FROM PSSIG.CLNT_ACCOUNTS INNER JOIN PSSIG.CLNT_CUSTOMERS ON
PSSIG.CLNT_ACCOUNTS.CSTMR_OID = PSSIG.CLNT_CUSTOMERS.CSTMR_OID
WHERE (PSSIG.CLNT_CUSTOMERS.CSTMR_START_DT >= '1900-1-1 12:00:00') AND
(PSSIG.CLNT_CUSTOMERS.CSTMR_END_DT <= '2106-12-31 12:00:00') AND
(PSSIG.CLNT_ACCOUNTS.ACC_KEY1 >= '0000000000000') AND
(PSSIG.CLNT_ACCOUNTS.ACC_KEY1 <= '9999999999999') AND
(PSSIG.CLNT_ACCOUNTS.ACC_STATUS_LAST = 5 ) AND
ACC_KEY1 > '0' ORDER BY ACC_KEY1
Note 1: value 5 exist in most of rows about ( 999999/1000000 ) from the table rows count
Note 2: the number of rows in each table around 15000000
Note 3: I used the same index structure for both DB2 and SQL server 2000
Note 4: I used some other feature in DB2 that increase the performance but I did not
found the alternative for it in SQL server 2000 :
a- cardinality varies at run time feature
b- include column in index instead of use compound index for
( ACC_KEY1 ,ACC_STATUS_LAST ) columns
Note 5 : Enable reverse scan for index



Um, why are you using strings to store the ACC_KEY1? Numeric fields are much faster.

I would suggest that you drop all your indexes that relate to that query. Then run the Database Engine Tuning Advisor (or whatever its called in SQL 2000) to determine what the right indexes are. Unless you know SQL Server intimately, it can generate better indexes than you can by hand.

Jonathan

|||

thank you for you advice , i use the tuuning wizard but it did not improve the performance

- and acc_key1 could contain a letter so it must be a string

|||

You use the same indexes, but what does those indexes look like?

What is the volume to be returned? Is the expected output close to a million rows? (all the '5's)

How do you measure the time? Do you look at the server for the time it takes to resolve the query, or do you measure at the 'end-point'? (ie if you select... and wait until a million rows has been drawn on the screen, or similar)

/Kenneth

Thursday, February 16, 2012

A problem about ADO!

i visit db with ado interface, but now i hava a sql like below:

select * into #t1 from measureInfo; select * from #t1; drop table #t1;

it can't execute with ado. Does Ado not support sql operation like this?

thks

Yes.. You can do this...execute the below query it will work..

Set NOCOUNT ON;select * into #t1 from measureInfo; select * from #t1; drop table #t1;

Saturday, February 11, 2012

A list of Auto exec SPs

Hello All,
A SP can be made to automatically execute when SQLServer restarts using the
store procedure "sp_procoption".
But is there a way to find out the list of SPs that have been congifured to
execute automatically. I took over as a DBA for an existing system and I was
wondering if there are any SP configured this way.
Thanks,
rgnIf you look at the definition for sp_procoption, you will discover the
following line of code:
UPDATE sysobjects SET status = (status & ~2) | (2 * @.intOptionValue) WHERE
id = @.tabid
This tells you, along with the rest of the definition, that if you query the
master.dbo.sysobjects table for status values of 2 on xtypes of X or P you
will find you startup procs and extended procs.
Sincerely,
Anthony Thomas
"rgn" <rgn@.discussions.microsoft.com> wrote in message
news:3DE27C29-DEDC-4D0B-AEB0-2C34553BB3E7@.microsoft.com...
> Hello All,
> A SP can be made to automatically execute when SQLServer restarts using
the
> store procedure "sp_procoption".
> But is there a way to find out the list of SPs that have been congifured
to
> execute automatically. I took over as a DBA for an existing system and I
was
> wondering if there are any SP configured this way.
> Thanks,
> rgn|||Hi rgn
You can use the OBJECTPROPERTY function.
SELECT name
FROM sysobjects
WHERE type = 'P'
AND OBJECTPROPERTY(id, 'ExecIsStartup') =1
--
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"rgn" <rgn@.discussions.microsoft.com> wrote in message
news:3DE27C29-DEDC-4D0B-AEB0-2C34553BB3E7@.microsoft.com...
> Hello All,
> A SP can be made to automatically execute when SQLServer restarts using
> the
> store procedure "sp_procoption".
> But is there a way to find out the list of SPs that have been congifured
> to
> execute automatically. I took over as a DBA for an existing system and I
> was
> wondering if there are any SP configured this way.
> Thanks,
> rgn

A list of Auto exec SPs

Hello All,
A SP can be made to automatically execute when SQLServer restarts using the
store procedure "sp_procoption".
But is there a way to find out the list of SPs that have been congifured to
execute automatically. I took over as a DBA for an existing system and I was
wondering if there are any SP configured this way.
Thanks,
rgn
If you look at the definition for sp_procoption, you will discover the
following line of code:
UPDATE sysobjects SET status = (status & ~2) | (2 * @.intOptionValue) WHERE
id = @.tabid
This tells you, along with the rest of the definition, that if you query the
master.dbo.sysobjects table for status values of 2 on xtypes of X or P you
will find you startup procs and extended procs.
Sincerely,
Anthony Thomas

"rgn" <rgn@.discussions.microsoft.com> wrote in message
news:3DE27C29-DEDC-4D0B-AEB0-2C34553BB3E7@.microsoft.com...
> Hello All,
> A SP can be made to automatically execute when SQLServer restarts using
the
> store procedure "sp_procoption".
> But is there a way to find out the list of SPs that have been congifured
to
> execute automatically. I took over as a DBA for an existing system and I
was
> wondering if there are any SP configured this way.
> Thanks,
> rgn
|||Hi rgn
You can use the OBJECTPROPERTY function.
SELECT name
FROM sysobjects
WHERE type = 'P'
AND OBJECTPROPERTY(id, 'ExecIsStartup') =1
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"rgn" <rgn@.discussions.microsoft.com> wrote in message
news:3DE27C29-DEDC-4D0B-AEB0-2C34553BB3E7@.microsoft.com...
> Hello All,
> A SP can be made to automatically execute when SQLServer restarts using
> the
> store procedure "sp_procoption".
> But is there a way to find out the list of SPs that have been congifured
> to
> execute automatically. I took over as a DBA for an existing system and I
> was
> wondering if there are any SP configured this way.
> Thanks,
> rgn

A list of Auto exec SPs

Hello All,
A SP can be made to automatically execute when SQLServer restarts using the
store procedure "sp_procoption".
But is there a way to find out the list of SPs that have been congifured to
execute automatically. I took over as a DBA for an existing system and I was
wondering if there are any SP configured this way.
Thanks,
rgnIf you look at the definition for sp_procoption, you will discover the
following line of code:
UPDATE sysobjects SET status = (status & ~2) | (2 * @.intOptionValue) WHERE
id = @.tabid
This tells you, along with the rest of the definition, that if you query the
master.dbo.sysobjects table for status values of 2 on xtypes of X or P you
will find you startup procs and extended procs.
Sincerely,
Anthony Thomas
"rgn" <rgn@.discussions.microsoft.com> wrote in message
news:3DE27C29-DEDC-4D0B-AEB0-2C34553BB3E7@.microsoft.com...
> Hello All,
> A SP can be made to automatically execute when SQLServer restarts using
the
> store procedure "sp_procoption".
> But is there a way to find out the list of SPs that have been congifured
to
> execute automatically. I took over as a DBA for an existing system and I
was
> wondering if there are any SP configured this way.
> Thanks,
> rgn|||Hi rgn
You can use the OBJECTPROPERTY function.
SELECT name
FROM sysobjects
WHERE type = 'P'
AND OBJECTPROPERTY(id, 'ExecIsStartup') =1
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"rgn" <rgn@.discussions.microsoft.com> wrote in message
news:3DE27C29-DEDC-4D0B-AEB0-2C34553BB3E7@.microsoft.com...
> Hello All,
> A SP can be made to automatically execute when SQLServer restarts using
> the
> store procedure "sp_procoption".
> But is there a way to find out the list of SPs that have been congifured
> to
> execute automatically. I took over as a DBA for an existing system and I
> was
> wondering if there are any SP configured this way.
> Thanks,
> rgn

A JOIN gives me more rows than I expected

Hello,
I've two tables AZ01 and AZ02 the structure is the same.
Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
I expect that the maximum number of rows is 1.681.000, but at the end I
get 1.684.000 rows!!! How is it possible?
Thanks for your help!
Perhaps SELECT COUNT(DISTINCT col)
"Andrea" <andy@.foo.com> wrote in message
news:e0rg1KkRFHA.1208@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've two tables AZ01 and AZ02 the structure is the same.
> Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
> I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
> AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
> I expect that the maximum number of rows is 1.681.000, but at the end I
> get 1.684.000 rows!!! How is it possible?
> Thanks for your help!
|||If the Key you reference is not unique in the Table AZ02 you will get those
"doubles". It will count the number of rows in the results which match which
each other.
Have a look at this example:
Use Northwind
GO
Select count(Orders.OrderID) From Orders
--> 830
Select count(Orders.OrderID) From Orders inner join [Order Details] OD ON
OD.OrderID = Orders.OrderId
--> 2155
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
"Andrea" <andy@.foo.com> schrieb im Newsbeitrag
news:e0rg1KkRFHA.1208@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've two tables AZ01 and AZ02 the structure is the same.
> Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
> I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
> AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
> I expect that the maximum number of rows is 1.681.000, but at the end I
> get 1.684.000 rows!!! How is it possible?
> Thanks for your help!

A JOIN gives me more rows than I expected

Hello,
I've two tables AZ01 and AZ02 the structure is the same.
Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
I expect that the maximum number of rows is 1.681.000, but at the end I
get 1.684.000 rows!!! How is it possible?
Thanks for your help!Perhaps SELECT COUNT(DISTINCT col)
"Andrea" <andy@.foo.com> wrote in message
news:e0rg1KkRFHA.1208@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've two tables AZ01 and AZ02 the structure is the same.
> Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
> I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
> AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
> I expect that the maximum number of rows is 1.681.000, but at the end I
> get 1.684.000 rows!!! How is it possible?
> Thanks for your help!|||If the Key you reference is not unique in the Table AZ02 you will get those
"doubles". It will count the number of rows in the results which match which
each other.
Have a look at this example:
Use Northwind
GO
Select count(Orders.OrderID) From Orders
--> 830
Select count(Orders.OrderID) From Orders inner join [Order Details] OD O
N
OD.OrderID = Orders.OrderId
--> 2155
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Andrea" <andy@.foo.com> schrieb im Newsbeitrag
news:e0rg1KkRFHA.1208@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've two tables AZ01 and AZ02 the structure is the same.
> Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
> I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
> AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
> I expect that the maximum number of rows is 1.681.000, but at the end I
> get 1.684.000 rows!!! How is it possible?
> Thanks for your help!

A JOIN gives me more rows than I expected

Hello,
I've two tables AZ01 and AZ02 the structure is the same.
Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
I expect that the maximum number of rows is 1.681.000, but at the end I
get 1.684.000 rows!!! How is it possible?
Thanks for your help!Perhaps SELECT COUNT(DISTINCT col)
"Andrea" <andy@.foo.com> wrote in message
news:e0rg1KkRFHA.1208@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've two tables AZ01 and AZ02 the structure is the same.
> Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
> I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
> AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
> I expect that the maximum number of rows is 1.681.000, but at the end I
> get 1.684.000 rows!!! How is it possible?
> Thanks for your help!|||If the Key you reference is not unique in the Table AZ02 you will get those
"doubles". It will count the number of rows in the results which match which
each other.
Have a look at this example:
Use Northwind
GO
Select count(Orders.OrderID) From Orders
--> 830
Select count(Orders.OrderID) From Orders inner join [Order Details] OD ON
OD.OrderID = Orders.OrderId
--> 2155
HTH, Jens Suessmeyer.
--
http://www.sqlserver2005.de
--
"Andrea" <andy@.foo.com> schrieb im Newsbeitrag
news:e0rg1KkRFHA.1208@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've two tables AZ01 and AZ02 the structure is the same.
> Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
> I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
> AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
> I expect that the maximum number of rows is 1.681.000, but at the end I
> get 1.684.000 rows!!! How is it possible?
> Thanks for your help!