Hi,
Can I use @.@.ERROR global variable to check the error returned by SQL DDL
commands.Are you saying that it doesn't work? Can you elaborate on your question? Som
e error will terminate
the batch. I suggest you check the two articles on error handling here: http://www
.sommarskog.se/
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>|||IN addition to Tibor's comments, and you will find included in Erlands
articles.
Yes you can ( and should) use @.@.error to check DDL... You might also check
for existence of the object or column, etc..
The problem is that some errors cause the entire batch, or maybe just the
statement to abort, in which case, the rest of your code wouldn't run or
@.@.error might not be set appropriately..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>
Showing posts with label returned. Show all posts
Showing posts with label returned. Show all posts
Tuesday, March 27, 2012
About @@ERROR
Hi,
Can I use @.@.ERROR global variable to check the error returned by SQL DDL
commands.
Are you saying that it doesn't work? Can you elaborate on your question? Some error will terminate
the batch. I suggest you check the two articles on error handling here: http://www.sommarskog.se/
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>
|||IN addition to Tibor's comments, and you will find included in Erlands
articles.
Yes you can ( and should) use @.@.error to check DDL... You might also check
for existence of the object or column, etc..
The problem is that some errors cause the entire batch, or maybe just the
statement to abort, in which case, the rest of your code wouldn't run or
@.@.error might not be set appropriately..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>
Can I use @.@.ERROR global variable to check the error returned by SQL DDL
commands.
Are you saying that it doesn't work? Can you elaborate on your question? Some error will terminate
the batch. I suggest you check the two articles on error handling here: http://www.sommarskog.se/
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>
|||IN addition to Tibor's comments, and you will find included in Erlands
articles.
Yes you can ( and should) use @.@.error to check DDL... You might also check
for existence of the object or column, etc..
The problem is that some errors cause the entire batch, or maybe just the
statement to abort, in which case, the rest of your code wouldn't run or
@.@.error might not be set appropriately..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>
About @@ERROR
Hi,
Can I use @.@.ERROR global variable to check the error returned by SQL DDL
commands.Are you saying that it doesn't work? Can you elaborate on your question? Some error will terminate
the batch. I suggest you check the two articles on error handling here: http://www.sommarskog.se/
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>|||IN addition to Tibor's comments, and you will find included in Erlands
articles.
Yes you can ( and should) use @.@.error to check DDL... You might also check
for existence of the object or column, etc..
The problem is that some errors cause the entire batch, or maybe just the
statement to abort, in which case, the rest of your code wouldn't run or
@.@.error might not be set appropriately..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>
Can I use @.@.ERROR global variable to check the error returned by SQL DDL
commands.Are you saying that it doesn't work? Can you elaborate on your question? Some error will terminate
the batch. I suggest you check the two articles on error handling here: http://www.sommarskog.se/
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>|||IN addition to Tibor's comments, and you will find included in Erlands
articles.
Yes you can ( and should) use @.@.error to check DDL... You might also check
for existence of the object or column, etc..
The problem is that some errors cause the entire batch, or maybe just the
statement to abort, in which case, the rest of your code wouldn't run or
@.@.error might not be set appropriately..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Shri.DBA" <ShriDBA@.discussions.microsoft.com> wrote in message
news:4CC53AC2-1747-4C8F-851B-2D057A2487E7@.microsoft.com...
> Hi,
> Can I use @.@.ERROR global variable to check the error returned by SQL DDL
> commands.
>
Sunday, March 11, 2012
a sql issue....any solutions?
If i want to select antim_id from following table using query
Q1...which has all the missile_id values returned by another query Q2
.
For eg. if Q2 returns 100,300,400
my Q1 should return 3000...How to do it.? Will using ALL will help?
DEFUSE_CAPABILITY
+--+--+
| antim_id | missile_id |
+--+--+
| 1000 | 100 |
| 1000 | 200 |
| 2000 | 100 |
| 2000 | 200 |
| 2000 | 300 |
| 3000 | 100 |
| 3000 | 200 |
| 3000 | 300 |
| 3000 | 400 |
| 3000 | 500 |
+--+--+
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/Programming...54.h
tml
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz
.com/eform.php?p=769680SELECT D.antim_id
FROM defuse_capability AS D
JOIN (SELECT missile_id FROM Q2) AS Q2
ON D.missile_id = Q2.missile_id
GROUP BY D.antim_id
HAVING COUNT(*)=
(SELECT COUNT(*)
FROM Q2)
David Portas
SQL Server MVP
--|||That's relational division:
http://www.examnotes.net/gurus/articles/113.asp
Jacco Schalkwijk
SQL Server MVP
"bishu" <UseLinkToEmail@.dbForumz.com> wrote in message
news:4_769680_998784ccb95151a62f2e182992
e143ac@.dbforumz.com...
> If i want to select antim_id from following table using query
> Q1...which has all the missile_id values returned by another query Q2
> .
> For eg. if Q2 returns 100,300,400
> my Q1 should return 3000...How to do it.? Will using ALL will help?
> DEFUSE_CAPABILITY
> +--+--+
> | antim_id | missile_id |
> +--+--+
> | 1000 | 100 |
> | 1000 | 200 |
> | 2000 | 100 |
> | 2000 | 200 |
> | 2000 | 300 |
> | 3000 | 100 |
> | 3000 | 200 |
> | 3000 | 300 |
> | 3000 | 400 |
> | 3000 | 500 |
> +--+--+
> --
> Posted using the http://www.dbforumz.com interface, at author's request
> Articles individually checked for conformance to usenet standards
> Topic URL:
> http://www.dbforumz.com/Programming...pict223454.html
> Visit Topic URL to contact author (reg. req'd). Report abuse:
> http://www.dbforumz.com/eform.php?p=769680|||"David Portas" wrote:
> SELECT D.antim_id
> FROM defuse_capability AS D
> JOIN (SELECT missile_id FROM Q2) AS Q2
> ON D.missile_id = Q2.missile_id
> GROUP BY D.antim_id
> HAVING COUNT(*)=
> (SELECT COUNT(*)
> FROM Q2)
> --
> David Portas
> SQL Server MVP
> --
Same problem i am simplifying...
David can you translate your sql query so that i can understand
better.
In the emp table if i want to select emp_id which has all the
account_id in accounts what is the select statement i need to write.
for eg : if account_id {100,300,400} then my output should be 3000
if account_id {100,200} - op is 1000,2000,3000
if account_id {100,300} - op is 2000,3000
table:emp
+--+--+
| empid_id | account |
+--+--+
| 1000 | 100 |
| 1000 | 200 |
| 2000 | 100 |
| 2000 | 200 |
| 2000 | 300 |
| 3000 | 100 |
| 3000 | 200 |
| 3000 | 300 |
| 3000 | 400 |
| 3000 | 500 |
+--+--+
table : account
+--+
| account_id |
+--+
| 100 |
| 300 |
| 400 |
+--+
can u just let me know the solution..
thanks a lot
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/Programming...54.h
tml
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz
.com/eform.php?p=769869|||In my original query just replace defuse_capability with Emp and Q2
with Account.
David Portas
SQL Server MVP
--
Q1...which has all the missile_id values returned by another query Q2
.
For eg. if Q2 returns 100,300,400
my Q1 should return 3000...How to do it.? Will using ALL will help?
DEFUSE_CAPABILITY
+--+--+
| antim_id | missile_id |
+--+--+
| 1000 | 100 |
| 1000 | 200 |
| 2000 | 100 |
| 2000 | 200 |
| 2000 | 300 |
| 3000 | 100 |
| 3000 | 200 |
| 3000 | 300 |
| 3000 | 400 |
| 3000 | 500 |
+--+--+
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/Programming...54.h
tml
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz
.com/eform.php?p=769680SELECT D.antim_id
FROM defuse_capability AS D
JOIN (SELECT missile_id FROM Q2) AS Q2
ON D.missile_id = Q2.missile_id
GROUP BY D.antim_id
HAVING COUNT(*)=
(SELECT COUNT(*)
FROM Q2)
David Portas
SQL Server MVP
--|||That's relational division:
http://www.examnotes.net/gurus/articles/113.asp
Jacco Schalkwijk
SQL Server MVP
"bishu" <UseLinkToEmail@.dbForumz.com> wrote in message
news:4_769680_998784ccb95151a62f2e182992
e143ac@.dbforumz.com...
> If i want to select antim_id from following table using query
> Q1...which has all the missile_id values returned by another query Q2
> .
> For eg. if Q2 returns 100,300,400
> my Q1 should return 3000...How to do it.? Will using ALL will help?
> DEFUSE_CAPABILITY
> +--+--+
> | antim_id | missile_id |
> +--+--+
> | 1000 | 100 |
> | 1000 | 200 |
> | 2000 | 100 |
> | 2000 | 200 |
> | 2000 | 300 |
> | 3000 | 100 |
> | 3000 | 200 |
> | 3000 | 300 |
> | 3000 | 400 |
> | 3000 | 500 |
> +--+--+
> --
> Posted using the http://www.dbforumz.com interface, at author's request
> Articles individually checked for conformance to usenet standards
> Topic URL:
> http://www.dbforumz.com/Programming...pict223454.html
> Visit Topic URL to contact author (reg. req'd). Report abuse:
> http://www.dbforumz.com/eform.php?p=769680|||"David Portas" wrote:
> SELECT D.antim_id
> FROM defuse_capability AS D
> JOIN (SELECT missile_id FROM Q2) AS Q2
> ON D.missile_id = Q2.missile_id
> GROUP BY D.antim_id
> HAVING COUNT(*)=
> (SELECT COUNT(*)
> FROM Q2)
> --
> David Portas
> SQL Server MVP
> --
Same problem i am simplifying...
David can you translate your sql query so that i can understand
better.
In the emp table if i want to select emp_id which has all the
account_id in accounts what is the select statement i need to write.
for eg : if account_id {100,300,400} then my output should be 3000
if account_id {100,200} - op is 1000,2000,3000
if account_id {100,300} - op is 2000,3000
table:emp
+--+--+
| empid_id | account |
+--+--+
| 1000 | 100 |
| 1000 | 200 |
| 2000 | 100 |
| 2000 | 200 |
| 2000 | 300 |
| 3000 | 100 |
| 3000 | 200 |
| 3000 | 300 |
| 3000 | 400 |
| 3000 | 500 |
+--+--+
table : account
+--+
| account_id |
+--+
| 100 |
| 300 |
| 400 |
+--+
can u just let me know the solution..
thanks a lot
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/Programming...54.h
tml
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz
.com/eform.php?p=769869|||In my original query just replace defuse_capability with Emp and Q2
with Account.
David Portas
SQL Server MVP
--
Subscribe to:
Posts (Atom)