[quoted text, click to view] On Fri, 13 Aug 2004 12:11:02 -0400, <jason@catamaranco.com> wrote:
>Damn, I'm stupid....too little sleep is my excuse! This works:
>
>UPDATE State
>SET StateBln = '1'
>WHERE (StateID > 0)
>
>Many thanks Bob
>Jason
You could do the following as well if a row doesn't exist in a table
then add a new row or update an existing one.
IF EXISTS(SELECT StateID FROM State WHERE StateID > 0)
BEGIN
UPDATE State SET StateBln='1' WHERE StateID>0
-- Some Error checking code here
END
ELSE
BEGIN
INSERT INTO State(StateBln) VALUES('1')
-- Some Error checking code here
END
Also please don't top post on usenet.
HTH
Al
[quoted text, click to view] >"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>news:elidO6UgEHA.704@TK2MSFTNGP12.phx.gbl...
>> jason@catamaranco.com wrote:
>> > How does one execute a one time INSERT query inside the data window
>> > of a particular table for all records >1...
>> >
>> > The table has referential integrity on StateID...here is my stab but
>> > I am picking up a SYNTAX ERROR near 'Begin':
>> >
>> >
>> > IF (SELECT StateID
>> > FROM State
>> > WHERE StateID > 0) BEGIN
>> > (INSERT
>> > INTO State(StateBln)
>> > VALUES (1)
>> > WHERE StateID > 0) END
>> >
>> > The query needs to deposit the Int value (1) into newly created column
>> > StateBln...
>> >
>> You can't use WHERE with VALUES. What are you trying to do? Insert a new
>> record? If so, you don't need a WHERE clause do you? Or are you trying to
>> update an existing record? If so, you need to use an UPDATE statement, not
>> an INSERT.
>>
>> Bob Barrows
>> --
>> Microsoft MVP - ASP/ASP.NET
>> Please reply to the newsgroup. This email account is my spam trap so I
>> don't check it very often. If you must reply off-line, then remove the
>> "NO SPAM"
>>
>>
>
[quoted text, click to view] On Fri, 13 Aug 2004 14:08:54 -0400, <jason@catamaranco.com> wrote:
>Awesome!!! many thanks.
No probs. :)
[quoted text, click to view] >
>ps: 'Top post' ? Not sure what this means....?
Top Post is exactly this posting at the very top of all the replies
rather than posting below what your actually replying to.
Personally I don't mind it (saves me scrolling down) as I read this
using a offline browser and but a lot of people mind. so I've now
started not to top post as well.
HTH
Al.
[quoted text, click to view] >
>-Jason
>"Harag" <haragREMOVETHESECAPITALS@softhome.net> wrote in message
>news:07vph0hl1n6m0eb497d8aa24dqq6u7o6gh@4ax.com...
>> On Fri, 13 Aug 2004 12:11:02 -0400, <jason@catamaranco.com> wrote:
>>
>> >Damn, I'm stupid....too little sleep is my excuse! This works:
>> >
>> >UPDATE State
>> >SET StateBln = '1'
>> >WHERE (StateID > 0)
>> >
>> >Many thanks Bob
>> >Jason
>>
>>
>> You could do the following as well if a row doesn't exist in a table
>> then add a new row or update an existing one.
>>
>>
>> IF EXISTS(SELECT StateID FROM State WHERE StateID > 0)
>> BEGIN
>> UPDATE State SET StateBln='1' WHERE StateID>0
>> -- Some Error checking code here
>> END
>> ELSE
>> BEGIN
>> INSERT INTO State(StateBln) VALUES('1')
>> -- Some Error checking code here
>> END
>>
>>
>> Also please don't top post on usenet.
>>
>>
>> HTH
>>
>> Al
>>
>>
>> >"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>> >news:elidO6UgEHA.704@TK2MSFTNGP12.phx.gbl...
>> >> jason@catamaranco.com wrote:
>> >> > How does one execute a one time INSERT query inside the data window
>> >> > of a particular table for all records >1...
>> >> >
>> >> > The table has referential integrity on StateID...here is my stab but
>> >> > I am picking up a SYNTAX ERROR near 'Begin':
>> >> >
>> >> >
>> >> > IF (SELECT StateID
>> >> > FROM State
>> >> > WHERE StateID > 0) BEGIN
>> >> > (INSERT
>> >> > INTO State(StateBln)
>> >> > VALUES (1)
>> >> > WHERE StateID > 0) END
>> >> >
>> >> > The query needs to deposit the Int value (1) into newly created
>column
>> >> > StateBln...
>> >> >
>> >> You can't use WHERE with VALUES. What are you trying to do? Insert a
>new
>> >> record? If so, you don't need a WHERE clause do you? Or are you trying
>to
>> >> update an existing record? If so, you need to use an UPDATE statement,
>not
>> >> an INSERT.
>> >>
>> >> Bob Barrows
>> >> --
>> >> Microsoft MVP - ASP/ASP.NET
>> >> Please reply to the newsgroup. This email account is my spam trap so I
>> >> don't check it very often. If you must reply off-line, then remove the
>> >> "NO SPAM"
>> >>
>> >>
>> >
>>
>
[quoted text, click to view] On Fri, 13 Aug 2004 14:08:54 -0400, <jason@catamaranco.com> wrote:
>Awesome!!! many thanks.
>
>ps: 'Top post' ? Not sure what this means....?
>
just found this url that might exaplain it better than I did:
http://www.caliburn.nl/topposting.html HTH
Al
[quoted text, click to view] >-Jason
>"Harag" <haragREMOVETHESECAPITALS@softhome.net> wrote in message
>news:07vph0hl1n6m0eb497d8aa24dqq6u7o6gh@4ax.com...
>> On Fri, 13 Aug 2004 12:11:02 -0400, <jason@catamaranco.com> wrote:
>>
>> >Damn, I'm stupid....too little sleep is my excuse! This works:
>> >
>> >UPDATE State
>> >SET StateBln = '1'
>> >WHERE (StateID > 0)
>> >
>> >Many thanks Bob
>> >Jason
>>
>>
>> You could do the following as well if a row doesn't exist in a table
>> then add a new row or update an existing one.
>>
>>
>> IF EXISTS(SELECT StateID FROM State WHERE StateID > 0)
>> BEGIN
>> UPDATE State SET StateBln='1' WHERE StateID>0
>> -- Some Error checking code here
>> END
>> ELSE
>> BEGIN
>> INSERT INTO State(StateBln) VALUES('1')
>> -- Some Error checking code here
>> END
>>
>>
>> Also please don't top post on usenet.
>>
>>
>> HTH
>>
>> Al
>>
>>
>> >"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>> >news:elidO6UgEHA.704@TK2MSFTNGP12.phx.gbl...
>> >> jason@catamaranco.com wrote:
>> >> > How does one execute a one time INSERT query inside the data window
>> >> > of a particular table for all records >1...
>> >> >
>> >> > The table has referential integrity on StateID...here is my stab but
>> >> > I am picking up a SYNTAX ERROR near 'Begin':
>> >> >
>> >> >
>> >> > IF (SELECT StateID
>> >> > FROM State
>> >> > WHERE StateID > 0) BEGIN
>> >> > (INSERT
>> >> > INTO State(StateBln)
>> >> > VALUES (1)
>> >> > WHERE StateID > 0) END
>> >> >
>> >> > The query needs to deposit the Int value (1) into newly created
>column
>> >> > StateBln...
>> >> >
>> >> You can't use WHERE with VALUES. What are you trying to do? Insert a
>new
>> >> record? If so, you don't need a WHERE clause do you? Or are you trying
>to
>> >> update an existing record? If so, you need to use an UPDATE statement,
>not
>> >> an INSERT.
>> >>
>> >> Bob Barrows
>> >> --
>> >> Microsoft MVP - ASP/ASP.NET
>> >> Please reply to the newsgroup. This email account is my spam trap so I
>> >> don't check it very often. If you must reply off-line, then remove the
>> >> "NO SPAM"
>> >>
>> >>
>> >
>>
>
Don't see what you're looking for? Try a search.