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
 Need Help with Stored Procedure

Author  Topic 

Sling
Starting Member

2 Posts

Posted - 2011-08-09 : 16:13:33
I'm new to SQL programming and would greatly appreciate any help I can get. Here are my questions:

Is it possible to copy an old data that is displayed on a text box (in Web environment) to a new column called "Alias" and then update the new data that's entered into the text box to an "existing" column called "LastName" in SQL server 2000? If yes, how do I write my procedure? Please see my incomplete script below (it probably doesn't even make sense to you), but I needed to start somewhere.

CREATE PROCEDURE sp_KeepAlias @Alias VarChar(25)
AS
SELECT * FROM Information WHERE LastName = @Alias
INSERT INTO Information (Alias)
GO

Thanks!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-09 : 16:20:13
I can't tell if you want an update or an insert. But here you go:

UPDATE t1
SET Col1 = Col2
WHERE SomeCol = @var1

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

Subscribe to my blog
Go to Top of Page

Sling
Starting Member

2 Posts

Posted - 2011-08-09 : 16:30:19
Thank you Tara! Pardon me. What's the difference between INSERT and UPDATE?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-09 : 18:43:07
Insert is to add new rows. Update is to change existing rows.

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 -