update | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

update

How can I update a bit filed to true when I select some records from my app. whatI mean is when I select a record in my application, I want to make it as true in my bit filed. pls help. Thanks!
"He laughs best who laughs last"
Could you explain a little more? Update table set field = ?? where field2 = something and field3 = somethingelse……????? Luis Martin
Moderator
SQL-Server-Performance.com Although nature commences with reason and ends in experience it is necessary for us to do the opposite, that is to commence with experience and from this to proceed to investigate the reason.
Leonardo Da Vinci Nunca esperes el reconocimiento de tus hijos, eso ocurrirá luego de tu muerte
All postings are provided “AS IS” with no warranties for accuracy.
SQL Server bit column will have only two values either 0 or 1
If you want to set it to true assign it to non-zero value Madhivanan Failing to plan is Planning to fail
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Madhivanan</i><br /><br />SQL Server bit column will have only two values either 0 or 1<br />If you want to set it to true assign it to non-zero value<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">In other words, set it to 1. [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]
Might be a bit nit-picking, but a bit column can also be NULL. [<img src=’/community/emoticons/emotion-5.gif’ alt=’;)‘ />]<br /><br />–<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />Heute schon gebloggt?<a target="_blank" href=http://www.insidesql.de/blogs>http://www.insidesql.de/blogs</a><br />
I think I was not clear.
The thing is I was trying to update a bit field and then select records in a single sql query instead of using procedure for tht. Thanks!
"He laughs best who laughs last"

Cant you use this? Update ………
Select………. If not, give more details Madhivanan Failing to plan is Planning to fail
Maybe you want this:
update table
set bitColumn = 1, @column1 = column1, …
where …
Read BOL about local variables assignemnt inside update statement.
quote:Originally posted by Reddy I think I was not clear.
The thing is I was trying to update a bit field and then select records in a single sql query instead of using procedure for tht. Thanks!
"He laughs best who laughs last"
You can execute an UPDATE query and a SELECT query in a single batch, but they are two queries. It depends on your client application whether it allows you to do this – it may not like two separate queries in a batch, or it may not like the UPDATE statement when the connection is set to expect a result set (which you need to do for the SELECT query). Anyway, why can’t you just use the criteria that you would use for the UPDATE query as the filter for the SELECT query? If you give us a little more background ….
]]>