When I was doing DAO in Access I made sure that my table names did not =
contain any spaces for if they did I had to write my "SQL" statements a =
little differently.
I was following an exmple and had a SQL statment:
sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2" This is in ASP with =
Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. =
But if you go to the tables in the Northwind database in SQL 2000 it is =
shown as Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. =
So what I am wondering is when tables in SQL 2000 contain spaces like =
the above Order Deatails, is the SQL statement as I have written it =
irrelevant? Shouldn't it be:
sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2"
?
Thanks.
--=20
George Hester
__________________________________
Hi,
Use SQARE brackets [] incase if you have space inbetwen the object names.
sSQL1 = "UPDATE [Order Details] SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
Thanks
Hari
MCDBA
"George Hester" <hesterloli@.hotmail.com> wrote in message
news:e#lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not
contain any spaces for if they did I had to write my "SQL" statements a
little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
This is in ASP with Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But
if you go to the tables in the Northwind database in SQL 2000 it is shown as
Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. So
what I am wondering is when tables in SQL 2000 contain spaces like the above
Order Deatails, is the SQL statement as I have written it irrelevant?
Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
?
Thanks.
George Hester
__________________________________
|||The ANSI SQL compliant way is to enclose the name inside double-quotes. SQL Server also support square
brackets. I prefer the ANSI SQL Compliant way.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not contain any spaces for if they did I
had to write my "SQL" statements a little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2" This is in ASP with
Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But if you go to the tables in the
Northwind database in SQL 2000 it is shown as Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. So what I am wondering is when tables
in SQL 2000 contain spaces like the above Order Deatails, is the SQL statement as I have written it
irrelevant? Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
?
Thanks.
George Hester
__________________________________
|||OK then it would be:
sSQL1 =3D "UPDATE ""Order Details"" SET Quantity=3D5 WHERE OrderID=3D3 =
AND ProductID=3D2"
for VBScript?
--=20
George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote =
in message news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside =
double-quotes. SQL Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
>=20
> --=20
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>=20
>=20
> "George Hester" <hesterloli@.hotmail.com> wrote in message =
news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not =
contain any spaces for if they did I
> had to write my "SQL" statements a little differently.
>=20
> I was following an exmple and had a SQL statment:
>=20
> sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
>=20
> Anyway if you look at this statement the table is called OrderDetails. =
But if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the =
space.
>=20
> This is the only table in the Northwind database that conatins a =
space. So what I am wondering is when tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL =
statement as I have written it
> irrelevant? Shouldn't it be:
>=20
> sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 =
AND ProductID=3D2"
> ?
> Thanks.
>=20
> --=20
> George Hester
> __________________________________
>=20
>
|||Yep. Better yet, always quality the object name with the owner. :-)
UPDATE dbo."Order Details" SET...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:ujt2XRFQEHA.3220@.TK2MSFTNGP09.phx.gbl...
OK then it would be:
sSQL1 = "UPDATE ""Order Details"" SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
for VBScript?
George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside double-quotes. SQL Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not contain any spaces for if they did I
> had to write my "SQL" statements a little differently.
> I was following an exmple and had a SQL statment:
> sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
> Anyway if you look at this statement the table is called OrderDetails. But if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the space.
> This is the only table in the Northwind database that conatins a space. So what I am wondering is when
tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL statement as I have written it
> irrelevant? Shouldn't it be:
> sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
> ?
> Thanks.
> --
> George Hester
> __________________________________
>
Showing posts with label statements. Show all posts
Showing posts with label statements. Show all posts
Monday, March 19, 2012
Error in sample Northwind?
When I was doing DAO in Access I made sure that my table names did not = contain any spaces for if they did I had to write my "SQL" statements a = little differently.
I was following an exmple and had a SQL statment:
sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND = ProductID=3D2" This is in ASP with = Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. = But if you go to the tables in the Northwind database in SQL 2000 it is = shown as Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. = So what I am wondering is when tables in SQL 2000 contain spaces like = the above Order Deatails, is the SQL statement as I have written it = irrelevant? Shouldn't it be:
sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 AND = ProductID=3D2"
?
Thanks.
-- George Hester
__________________________________Hi,
Use SQARE brackets [] incase if you have space inbetwen the object names.
sSQL1 = "UPDATE [Order Details] SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
Thanks
Hari
MCDBA
"George Hester" <hesterloli@.hotmail.com> wrote in message
news:e#lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not
contain any spaces for if they did I had to write my "SQL" statements a
little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
This is in ASP with Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But
if you go to the tables in the Northwind database in SQL 2000 it is shown as
Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. So
what I am wondering is when tables in SQL 2000 contain spaces like the above
Order Deatails, is the SQL statement as I have written it irrelevant?
Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
?
Thanks.
--
George Hester
__________________________________|||The ANSI SQL compliant way is to enclose the name inside double-quotes. SQL Server also support square
brackets. I prefer the ANSI SQL Compliant way.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not contain any spaces for if they did I
had to write my "SQL" statements a little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2" This is in ASP with
Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But if you go to the tables in the
Northwind database in SQL 2000 it is shown as Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. So what I am wondering is when tables
in SQL 2000 contain spaces like the above Order Deatails, is the SQL statement as I have written it
irrelevant? Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
?
Thanks.
--
George Hester
__________________________________|||OK then it would be:
sSQL1 =3D "UPDATE ""Order Details"" SET Quantity=3D5 WHERE OrderID=3D3 =AND ProductID=3D2"
for VBScript?
-- George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote =in message news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside =double-quotes. SQL Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
> > -- > Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> > > "George Hester" <hesterloli@.hotmail.com> wrote in message =news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not =contain any spaces for if they did I
> had to write my "SQL" statements a little differently.
> > I was following an exmple and had a SQL statment:
> > sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND =ProductID=3D2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
> > Anyway if you look at this statement the table is called OrderDetails. = But if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the =space.
> > This is the only table in the Northwind database that conatins a =space. So what I am wondering is when tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL =statement as I have written it
> irrelevant? Shouldn't it be:
> > sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 =AND ProductID=3D2"
> ?
> Thanks.
> > -- > George Hester
> __________________________________
> >|||Yep. Better yet, always quality the object name with the owner. :-)
UPDATE dbo."Order Details" SET...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:ujt2XRFQEHA.3220@.TK2MSFTNGP09.phx.gbl...
OK then it would be:
sSQL1 = "UPDATE ""Order Details"" SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
for VBScript?
--
George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside double-quotes. SQL Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not contain any spaces for if they did I
> had to write my "SQL" statements a little differently.
> I was following an exmple and had a SQL statment:
> sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
> Anyway if you look at this statement the table is called OrderDetails. But if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the space.
> This is the only table in the Northwind database that conatins a space. So what I am wondering is when
tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL statement as I have written it
> irrelevant? Shouldn't it be:
> sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
> ?
> Thanks.
> --
> George Hester
> __________________________________
>
I was following an exmple and had a SQL statment:
sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND = ProductID=3D2" This is in ASP with = Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. = But if you go to the tables in the Northwind database in SQL 2000 it is = shown as Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. = So what I am wondering is when tables in SQL 2000 contain spaces like = the above Order Deatails, is the SQL statement as I have written it = irrelevant? Shouldn't it be:
sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 AND = ProductID=3D2"
?
Thanks.
-- George Hester
__________________________________Hi,
Use SQARE brackets [] incase if you have space inbetwen the object names.
sSQL1 = "UPDATE [Order Details] SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
Thanks
Hari
MCDBA
"George Hester" <hesterloli@.hotmail.com> wrote in message
news:e#lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not
contain any spaces for if they did I had to write my "SQL" statements a
little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
This is in ASP with Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But
if you go to the tables in the Northwind database in SQL 2000 it is shown as
Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. So
what I am wondering is when tables in SQL 2000 contain spaces like the above
Order Deatails, is the SQL statement as I have written it irrelevant?
Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
?
Thanks.
--
George Hester
__________________________________|||The ANSI SQL compliant way is to enclose the name inside double-quotes. SQL Server also support square
brackets. I prefer the ANSI SQL Compliant way.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not contain any spaces for if they did I
had to write my "SQL" statements a little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2" This is in ASP with
Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But if you go to the tables in the
Northwind database in SQL 2000 it is shown as Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. So what I am wondering is when tables
in SQL 2000 contain spaces like the above Order Deatails, is the SQL statement as I have written it
irrelevant? Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
?
Thanks.
--
George Hester
__________________________________|||OK then it would be:
sSQL1 =3D "UPDATE ""Order Details"" SET Quantity=3D5 WHERE OrderID=3D3 =AND ProductID=3D2"
for VBScript?
-- George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote =in message news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside =double-quotes. SQL Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
> > -- > Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> > > "George Hester" <hesterloli@.hotmail.com> wrote in message =news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not =contain any spaces for if they did I
> had to write my "SQL" statements a little differently.
> > I was following an exmple and had a SQL statment:
> > sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND =ProductID=3D2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
> > Anyway if you look at this statement the table is called OrderDetails. = But if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the =space.
> > This is the only table in the Northwind database that conatins a =space. So what I am wondering is when tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL =statement as I have written it
> irrelevant? Shouldn't it be:
> > sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 =AND ProductID=3D2"
> ?
> Thanks.
> > -- > George Hester
> __________________________________
> >|||Yep. Better yet, always quality the object name with the owner. :-)
UPDATE dbo."Order Details" SET...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:ujt2XRFQEHA.3220@.TK2MSFTNGP09.phx.gbl...
OK then it would be:
sSQL1 = "UPDATE ""Order Details"" SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
for VBScript?
--
George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside double-quotes. SQL Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not contain any spaces for if they did I
> had to write my "SQL" statements a little differently.
> I was following an exmple and had a SQL statment:
> sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
> Anyway if you look at this statement the table is called OrderDetails. But if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the space.
> This is the only table in the Northwind database that conatins a space. So what I am wondering is when
tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL statement as I have written it
> irrelevant? Shouldn't it be:
> sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
> ?
> Thanks.
> --
> George Hester
> __________________________________
>
Error in sample Northwind?
When I was doing DAO in Access I made sure that my table names did not =
contain any spaces for if they did I had to write my "SQL" statements a =
little differently.
I was following an exmple and had a SQL statment:
sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2" This is in ASP with =
Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. =
But if you go to the tables in the Northwind database in SQL 2000 it is =
shown as Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. =
So what I am wondering is when tables in SQL 2000 contain spaces like =
the above Order Deatails, is the SQL statement as I have written it =
irrelevant? Shouldn't it be:
sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2"
?
Thanks.
--=20
George Hester
__________________________________Hi,
Use SQARE brackets [] incase if you have space inbetwen the object names
.
sSQL1 = "UPDATE [Order Details] SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
Thanks
Hari
MCDBA
"George Hester" <hesterloli@.hotmail.com> wrote in message
news:e#lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not
contain any spaces for if they did I had to write my "SQL" statements a
little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
This is in ASP with Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But
if you go to the tables in the Northwind database in SQL 2000 it is shown as
Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. So
what I am wondering is when tables in SQL 2000 contain spaces like the above
Order Deatails, is the SQL statement as I have written it irrelevant?
Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
?
Thanks.
George Hester
__________________________________|||The ANSI SQL compliant way is to enclose the name inside double-quotes. SQL
Server also support square
brackets. I prefer the ANSI SQL Compliant way.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPEHA
.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not conta
in any spaces for if they did I
had to write my "SQL" statements a little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
This is in ASP with
Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But
if you go to the tables in the
Northwind database in SQL 2000 it is shown as Order Details. Note the space
.
This is the only table in the Northwind database that conatins a space. So
what I am wondering is when tables
in SQL 2000 contain spaces like the above Order Deatails, is the SQL stateme
nt as I have written it
irrelevant? Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND ProductID
=2"
?
Thanks.
George Hester
__________________________________|||OK then it would be:
sSQL1 =3D "UPDATE ""Order Details"" SET Quantity=3D5 WHERE OrderID=3D3 =
AND ProductID=3D2"
for VBScript?
--=20
George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote =
in message news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside =
double-quotes. SQL Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
>=20
> --=20
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>=20
>=20
> "George Hester" <hesterloli@.hotmail.com> wrote in message =
news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not =
contain any spaces for if they did I
> had to write my "SQL" statements a little differently.
>=20
> I was following an exmple and had a SQL statment:
>=20
> sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
>=20
> Anyway if you look at this statement the table is called OrderDetails. =
But if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the =
space.
>=20
> This is the only table in the Northwind database that conatins a =
space. So what I am wondering is when tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL =
statement as I have written it
> irrelevant? Shouldn't it be:
>=20
> sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 =
AND ProductID=3D2"
> ?
> Thanks.
>=20
> --=20
> George Hester
> __________________________________
>=20
>|||Yep. Better yet, always quality the object name with the owner. :-)
UPDATE dbo."Order Details" SET...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:ujt2XRFQEHA.3
220@.TK2MSFTNGP09.phx.gbl...
OK then it would be:
sSQL1 = "UPDATE ""Order Details"" SET Quantity=5 WHERE OrderID=3 AND Product
ID=2"
for VBScript?
George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message
news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside double-quotes. SQ
L Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPE
HA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not con
tain any spaces for if they did I
> had to write my "SQL" statements a little differently.
> I was following an exmple and had a SQL statment:
> sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=
2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
> Anyway if you look at this statement the table is called OrderDetails. Bu
t if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the spa
ce.
> This is the only table in the Northwind database that conatins a space. So what I
am wondering is when
tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL state
ment as I have written it
> irrelevant? Shouldn't it be:
> sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND Product
ID=2"
> ?
> Thanks.
> --
> George Hester
> __________________________________
>
contain any spaces for if they did I had to write my "SQL" statements a =
little differently.
I was following an exmple and had a SQL statment:
sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2" This is in ASP with =
Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. =
But if you go to the tables in the Northwind database in SQL 2000 it is =
shown as Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. =
So what I am wondering is when tables in SQL 2000 contain spaces like =
the above Order Deatails, is the SQL statement as I have written it =
irrelevant? Shouldn't it be:
sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2"
?
Thanks.
--=20
George Hester
__________________________________Hi,
Use SQARE brackets [] incase if you have space inbetwen the object names
.
sSQL1 = "UPDATE [Order Details] SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
Thanks
Hari
MCDBA
"George Hester" <hesterloli@.hotmail.com> wrote in message
news:e#lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not
contain any spaces for if they did I had to write my "SQL" statements a
little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
This is in ASP with Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But
if you go to the tables in the Northwind database in SQL 2000 it is shown as
Order Details. Note the space.
This is the only table in the Northwind database that conatins a space. So
what I am wondering is when tables in SQL 2000 contain spaces like the above
Order Deatails, is the SQL statement as I have written it irrelevant?
Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND
ProductID=2"
?
Thanks.
George Hester
__________________________________|||The ANSI SQL compliant way is to enclose the name inside double-quotes. SQL
Server also support square
brackets. I prefer the ANSI SQL Compliant way.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPEHA
.2128@.TK2MSFTNGP11.phx.gbl...
When I was doing DAO in Access I made sure that my table names did not conta
in any spaces for if they did I
had to write my "SQL" statements a little differently.
I was following an exmple and had a SQL statment:
sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=2"
This is in ASP with
Server.CreateObject("ADODB.Connection")
Anyway if you look at this statement the table is called OrderDetails. But
if you go to the tables in the
Northwind database in SQL 2000 it is shown as Order Details. Note the space
.
This is the only table in the Northwind database that conatins a space. So
what I am wondering is when tables
in SQL 2000 contain spaces like the above Order Deatails, is the SQL stateme
nt as I have written it
irrelevant? Shouldn't it be:
sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND ProductID
=2"
?
Thanks.
George Hester
__________________________________|||OK then it would be:
sSQL1 =3D "UPDATE ""Order Details"" SET Quantity=3D5 WHERE OrderID=3D3 =
AND ProductID=3D2"
for VBScript?
--=20
George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote =
in message news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside =
double-quotes. SQL Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
>=20
> --=20
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>=20
>=20
> "George Hester" <hesterloli@.hotmail.com> wrote in message =
news:e%23lSISoPEHA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not =
contain any spaces for if they did I
> had to write my "SQL" statements a little differently.
>=20
> I was following an exmple and had a SQL statment:
>=20
> sSQL1 =3D "UPDATE OrderDetails SET Quantity=3D5 WHERE OrderID=3D3 AND =
ProductID=3D2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
>=20
> Anyway if you look at this statement the table is called OrderDetails. =
But if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the =
space.
>=20
> This is the only table in the Northwind database that conatins a =
space. So what I am wondering is when tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL =
statement as I have written it
> irrelevant? Shouldn't it be:
>=20
> sSQL1 =3D "UPDATE 'Order Details' SET Quantity=3D5 WHERE OrderID=3D3 =
AND ProductID=3D2"
> ?
> Thanks.
>=20
> --=20
> George Hester
> __________________________________
>=20
>|||Yep. Better yet, always quality the object name with the owner. :-)
UPDATE dbo."Order Details" SET...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"George Hester" <hesterloli@.hotmail.com> wrote in message news:ujt2XRFQEHA.3
220@.TK2MSFTNGP09.phx.gbl...
OK then it would be:
sSQL1 = "UPDATE ""Order Details"" SET Quantity=5 WHERE OrderID=3 AND Product
ID=2"
for VBScript?
George Hester
__________________________________
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message
news:e519lOxPEHA.1644@.TK2MSFTNGP09.phx.gbl...
> The ANSI SQL compliant way is to enclose the name inside double-quotes. SQ
L Server also support square
> brackets. I prefer the ANSI SQL Compliant way.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "George Hester" <hesterloli@.hotmail.com> wrote in message news:e%23lSISoPE
HA.2128@.TK2MSFTNGP11.phx.gbl...
> When I was doing DAO in Access I made sure that my table names did not con
tain any spaces for if they did I
> had to write my "SQL" statements a little differently.
> I was following an exmple and had a SQL statment:
> sSQL1 = "UPDATE OrderDetails SET Quantity=5 WHERE OrderID=3 AND ProductID=
2" This is in ASP with
> Server.CreateObject("ADODB.Connection")
> Anyway if you look at this statement the table is called OrderDetails. Bu
t if you go to the tables in the
> Northwind database in SQL 2000 it is shown as Order Details. Note the spa
ce.
> This is the only table in the Northwind database that conatins a space. So what I
am wondering is when
tables
> in SQL 2000 contain spaces like the above Order Deatails, is the SQL state
ment as I have written it
> irrelevant? Shouldn't it be:
> sSQL1 = "UPDATE 'Order Details' SET Quantity=5 WHERE OrderID=3 AND Product
ID=2"
> ?
> Thanks.
> --
> George Hester
> __________________________________
>
Wednesday, February 15, 2012
Error handling in Stored procedure
I have some DML statements that can cause some errors. I want to handle
them gracefully and go ahead with the rest of the SQL statement. What
is the best approach for this?
Assuming that in a loop I am doing some delete that can cause some
foreign key violation.
Delete from MasterTable --This can cause error if there are child
tables refering to this .
How can I get the error message so that I can log it to a log table?
This is what I am doing
Open a cursor on Tabel List
While
BEGIN
@.DynamicSQL = 'Delete from ' + @.TableName--The tablename wil
change for each iteration
If @.@.Error<>0
Begin
--log error message
END
ELSE
Begin
--log Success message
END
END
I hope I have explained it well.
Thanks in advance> How can I get the error message so that I can log it to a log table?
In the client application. You can only get the error number at the TSQL lev
el, not the error
message. For more information, see the error handling articles at www.sommarskog.s
e.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"SQL novice" <balacr@.gmail.com> wrote in message
news:1132650496.640747.51460@.g14g2000cwa.googlegroups.com...
>I have some DML statements that can cause some errors. I want to handle
> them gracefully and go ahead with the rest of the SQL statement. What
> is the best approach for this?
> Assuming that in a loop I am doing some delete that can cause some
> foreign key violation.
> Delete from MasterTable --This can cause error if there are child
> tables refering to this .
> How can I get the error message so that I can log it to a log table?
> This is what I am doing
> Open a cursor on Tabel List
> While
> BEGIN
> @.DynamicSQL = 'Delete from ' + @.TableName--The tablename wil
> change for each iteration
> If @.@.Error<>0
> Begin
> --log error message
> END
> ELSE
> Begin
> --log Success message
> END
> END
>
> I hope I have explained it well.
> Thanks in advance
>|||Can I somehow force the next iteration to continue when there is some
error.
Here it is throwing the error and coming out when there is some error.
Thanks for your help|||Some type of errors will terminate the batch, most won't. It is all in the a
rticles I referred to.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"SQL novice" <balacr@.gmail.com> wrote in message
news:1132660588.888364.310040@.g47g2000cwa.googlegroups.com...
> Can I somehow force the next iteration to continue when there is some
> error.
> Here it is throwing the error and coming out when there is some error.
> Thanks for your help
>
them gracefully and go ahead with the rest of the SQL statement. What
is the best approach for this?
Assuming that in a loop I am doing some delete that can cause some
foreign key violation.
Delete from MasterTable --This can cause error if there are child
tables refering to this .
How can I get the error message so that I can log it to a log table?
This is what I am doing
Open a cursor on Tabel List
While
BEGIN
@.DynamicSQL = 'Delete from ' + @.TableName--The tablename wil
change for each iteration
If @.@.Error<>0
Begin
--log error message
END
ELSE
Begin
--log Success message
END
END
I hope I have explained it well.
Thanks in advance> How can I get the error message so that I can log it to a log table?
In the client application. You can only get the error number at the TSQL lev
el, not the error
message. For more information, see the error handling articles at www.sommarskog.s
e.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"SQL novice" <balacr@.gmail.com> wrote in message
news:1132650496.640747.51460@.g14g2000cwa.googlegroups.com...
>I have some DML statements that can cause some errors. I want to handle
> them gracefully and go ahead with the rest of the SQL statement. What
> is the best approach for this?
> Assuming that in a loop I am doing some delete that can cause some
> foreign key violation.
> Delete from MasterTable --This can cause error if there are child
> tables refering to this .
> How can I get the error message so that I can log it to a log table?
> This is what I am doing
> Open a cursor on Tabel List
> While
> BEGIN
> @.DynamicSQL = 'Delete from ' + @.TableName--The tablename wil
> change for each iteration
> If @.@.Error<>0
> Begin
> --log error message
> END
> ELSE
> Begin
> --log Success message
> END
> END
>
> I hope I have explained it well.
> Thanks in advance
>|||Can I somehow force the next iteration to continue when there is some
error.
Here it is throwing the error and coming out when there is some error.
Thanks for your help|||Some type of errors will terminate the batch, most won't. It is all in the a
rticles I referred to.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"SQL novice" <balacr@.gmail.com> wrote in message
news:1132660588.888364.310040@.g47g2000cwa.googlegroups.com...
> Can I somehow force the next iteration to continue when there is some
> error.
> Here it is throwing the error and coming out when there is some error.
> Thanks for your help
>
Subscribe to:
Posts (Atom)