Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 18th, 2005, 11:00 AM
Authorized User
 
Join Date: Dec 2004
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I refresh a table in store procedure

Hi there,
    I am wondering if anyone can help me solve this problem.Thanks you in advance!
Here is the table I am working on:
table user
user_id int(4),
user varchar(16),
password varchar(50)

Now I am trying to write a store procedure to implement follwoing tasks:


    -- Change size of [password] field to 255
    Alter Table sec_tmp
    alter column [password] varchar(255) NULL

    -- Insert a new column "password_tmp(varbinary)
    Alter Table dbo.sec_tmp ADD
    password_tmp varbinary(255) Null



    DECLARE upgrade CURSOR FOR
        SELECT [user id], [password] FROM sec_tmp

    OPEN upgrade

    FETCH NEXT FROM upgrade

    WHILE @@FETCH_STATUS = 0
        FETCH NEXT FROM upgrade
        update u
    set [password_tmp] = convert(varbinary(255),pwdencrypt([password]))
    from sec_tmp u

    CLOSE upgrade
    DEALLOCATE upgrade

    -- Delete password field
    -- Rename password_tmp to password
My problem is if I execute this store procedure, I always receive error msg saying "invalid column [password_tmp]".
I tried to first execute two "alter" commands, then refresh table, this store procedure works. My question is how
can I put those codes in a one or two store procedure to make it works automatically instead manually.

flyfish
__________________
flyfish
 
Old July 19th, 2005, 07:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Code:
update u
    set [password_tmp] = convert(varbinary(255),pwdencrypt([password]))
    from sec_tmp u
    What is U there? Is that you wanted to update sec_tmp table?

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Store procedure help... RinoDM SQL Server 2000 7 August 11th, 2008 07:09 PM
Store procedure help ??? RinoDM SQL Server 2000 8 May 1st, 2008 03:03 PM
store procedure, temp table kumiko SQL Language 2 January 15th, 2008 05:46 AM
Store Procedure sureshyuga SQL Server 2000 0 May 18th, 2007 01:49 AM
Can you pass a table to a store procedure? pbyrum SQL Language 1 January 26th, 2005 01:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.