Showing posts with label remaining. Show all posts
Showing posts with label remaining. Show all posts

Wednesday, March 7, 2012

how to store my results to another table

Hi guys,

now i was able to get the results of the query i made. and the remaining problem now is how can i store the results to my database?

here's the my code:


protected void btnGenerate_Click(object sender, EventArgs e)
{
_con = new SqlConnection(database.evgConnection());
_comm = new SqlCommand("EV_usp_SearchNoticeLocation", _con);
_comm.CommandType = CommandType.StoredProcedure;
_comm.Parameters.AddWithValue("@.Locationid", ddlLocation.SelectedValue);
_adapt = new SqlDataAdapter(_comm);
DataSet objDataset = new DataSet();
_adapt.Fill(objDataset);
GridView1.DataSource = objDataset;
GridView1.DataBind();

foreach(DataRow dr in objDataset.Tables[0].Rows)
{
Response.Write(dr["Docownerid"].ToString());
}
}

how can i store all the Docownerid to another database table?

you can write simple query which will create a new table in sql server from the select query result.

SelectfiledName intoNewTableName fromExistingTable.

i think this will help you.

Sanjay

Sunday, February 19, 2012

How to stop query in QA from continuing

Greetings everyone!

Is there a way to stop query analyzer from processing remaining query
statements? Let's say i have the following query in query analyzer:

query statements
if condition
begin
query statements
stop the query
end

query statements
if condition
begin
query statements
stop the query
end

is there a way to stop the query from executing the statements in the
second query when the first condition is met?

i have searched BOL and google but i couldn't find anything. I hope
anybody out there can help me.

BTW, i'm executing this statements directly in QA, not from within my
program. The query statement and if condition pair is plenty. i guess i
can use an else statement but it would be nested too deep. if there is
a simpler way to do it please point me to the right direction or to any
link that'll get me going.

Thanks in advance.

diegoYou can use GOTO. It will look like this:

query statements
if condition
begin
query statements
GOTO ExitQuery
end

query statements
if condition
begin
query statements
GOTO ExitQuery
end

ExitQuery:
GO

Be aware that GOTO cannot go to a label outside of the batch.

Regards,

Plamen Ratchev
http://www.SQLStudio.com
"diego" <diegobph@.yahoo.comwrote in message
news:1168144191.844124.221930@.11g2000cwr.googlegro ups.com...

Quote:

Originally Posted by

Greetings everyone!
>
Is there a way to stop query analyzer from processing remaining query
statements? Let's say i have the following query in query analyzer:
>
query statements
if condition
begin
query statements
stop the query
end
>
query statements
if condition
begin
query statements
stop the query
end
>
is there a way to stop the query from executing the statements in the
second query when the first condition is met?
>
i have searched BOL and google but i couldn't find anything. I hope
anybody out there can help me.
>
BTW, i'm executing this statements directly in QA, not from within my
program. The query statement and if condition pair is plenty. i guess i
can use an else statement but it would be nested too deep. if there is
a simpler way to do it please point me to the right direction or to any
link that'll get me going.
>
Thanks in advance.
>
diego
>

|||Thank you.

Ayon kay Plamen Ratchev:

Quote:

Originally Posted by

You can use GOTO. It will look like this:
>
query statements
if condition
begin
query statements
GOTO ExitQuery
end
>
query statements
if condition
begin
query statements
GOTO ExitQuery
end
>
ExitQuery:
GO
>
Be aware that GOTO cannot go to a label outside of the batch.
>
Regards,
>
Plamen Ratchev
http://www.SQLStudio.com
>
"diego" <diegobph@.yahoo.comwrote in message
news:1168144191.844124.221930@.11g2000cwr.googlegro ups.com...

Quote:

Originally Posted by

Greetings everyone!

Is there a way to stop query analyzer from processing remaining query
statements? Let's say i have the following query in query analyzer:

query statements
if condition
begin
query statements
stop the query
end

query statements
if condition
begin
query statements
stop the query
end

is there a way to stop the query from executing the statements in the
second query when the first condition is met?

i have searched BOL and google but i couldn't find anything. I hope
anybody out there can help me.

BTW, i'm executing this statements directly in QA, not from within my
program. The query statement and if condition pair is plenty. i guess i
can use an else statement but it would be nested too deep. if there is
a simpler way to do it please point me to the right direction or to any
link that'll get me going.

Thanks in advance.

diego

|||You could also use "RETURN".

-Dave
http://www.markleconsulting.com
diego wrote:

Quote:

Originally Posted by

Thank you.
>
Ayon kay Plamen Ratchev:

Quote:

Originally Posted by

You can use GOTO. It will look like this:

query statements
if condition
begin
query statements
GOTO ExitQuery
end

query statements
if condition
begin
query statements
GOTO ExitQuery
end

ExitQuery:
GO

Be aware that GOTO cannot go to a label outside of the batch.

Regards,

Plamen Ratchev
http://www.SQLStudio.com
"diego" <diegobph@.yahoo.comwrote in message
news:1168144191.844124.221930@.11g2000cwr.googlegro ups.com...

Quote:

Originally Posted by

Greetings everyone!
>
Is there a way to stop query analyzer from processing remaining query
statements? Let's say i have the following query in query analyzer:
>
query statements
if condition
begin
query statements
stop the query
end
>
query statements
if condition
begin
query statements
stop the query
end
>
is there a way to stop the query from executing the statements in the
second query when the first condition is met?
>
i have searched BOL and google but i couldn't find anything. I hope
anybody out there can help me.
>
BTW, i'm executing this statements directly in QA, not from within my
program. The query statement and if condition pair is plenty. i guess i
can use an else statement but it would be nested too deep. if there is
a simpler way to do it please point me to the right direction or to any
link that'll get me going.
>
Thanks in advance.
>
diego
>