Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 HELP WITH AN UPDATE STATEMENT!!!URGENT!

Author  Topic 

blahblahblah4332
Starting Member

2 Posts

Posted - 2010-09-23 : 22:37:23
I am working on an update form. So a user can update info in the database from an outside form. I just can't remember how to do an update statement. Here's what I have so far

"UPDATE `database_School`.`Majors` SET `academiclevel` = '' WHERE `Majors`.`majorid` =";

The form has them update the academic level and name, I don't know how to write it out though. I don't want a set value, so I need it empty, so they can put in the info in the form. Can someone please help me out? This is pretty urgent! Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-23 : 22:59:52
What makes this so urgent? People are less willing to help when people claim it's urgent.

Here's an example of a simple update statement:

UPDATE Table1
SET Column1 = @var1
WHERE Column2 = 4

What you do with @var1 is up to your application and not the responsibility of SQL Server.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

blahblahblah4332
Starting Member

2 Posts

Posted - 2010-09-23 : 23:09:19
Thanks for the help, it's urgent because it's due for a client tomorrow. The person who was supposed to help me it didn't show, and I haven't done update statements in a long time.

So when you have the @var1....could I leave that empty? I don't want any set variable in there, that's what I'm confused on, how do I get it to stay blank, just leave it empty?
Go to Top of Page

rohitvishwakarma
Posting Yak Master

232 Posts

Posted - 2010-09-24 : 03:43:42
quote:
Originally posted by blahblahblah4332

Thanks for the help, it's urgent because it's due for a client tomorrow. The person who was supposed to help me it didn't show, and I haven't done update statements in a long time.

So when you have the @var1....could I leave that empty? I don't want any set variable in there, that's what I'm confused on, how do I get it to stay blank, just leave it empty?



UPDATE Table1
SET Column1 = ''
WHERE Column2 = 4
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-24 : 12:16:49
Leaving it empty does not allow it to be filled in by the user. Leaving it empty means an empty value will be stored in the database.

This needs to be done inside your application.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -