Use the update query to specify the number of data

Source: Internet
Author: User

To do the stored procedure today, in the occasional thought of something,

That is, select can query for a single piece of data,

So why can't update?

Actually, it's okay.

After my special Niu Jiao Jian,

It's still out.

In QSL there is actually a query that is to use the update query a data,

Not much, just look at the code.

CREATE TABLE [dbo]. [Name] (---insert data after building table

[ID] [int] IDENTITY (1,1) not NULL,

[Name] [varchar] () not NULL,

[Age] [INT] Not NULL,

[Sex] [varchar] (ten) Not NULL,

[Shenggao] [INT] Not NULL,

[DESC] [varchar] (MB) Not NULL,

CONSTRAINT [Pk_name] PRIMARY KEY CLUSTERED

(

[ID] ASC

With (Pad_index = off, Statistics_norecompute = off, Ignore_dup_key = off, Allow_row_locks = on, allow_page_locks = ON) O N [PRIMARY]

) on [PRIMARY]

Go

DECLARE @ID int= ' 123456 '--number

DECLARE @C1 VARCHAR (50)--Specify the columns to be checked out

UPDATE [Name]

Set @C1 =[name]--fetch a column

WHERE id= @ID

Select @C1--Display column data

I'll test it out.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.