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
 Development Tools
 Other Development Tools
 Update SQL table script

Author  Topic 

emailuser
Yak Posting Veteran

74 Posts

Posted - 2011-09-14 : 07:06:54
Hi everyone , hope someone can help on my query ,

i have an sql server 2000 and a database called Data1, there is a table called status , which has columns for name , lastupdate, and status,

I am looking for a script to be run on each persons pc that we can add to the end of the users backup software to send the %username ( logged on user ) to the name column in the table, then send the current date to the lastupdate column, and finally a value to update the status table , .. i have tried several ways but cannot get it to work .. any help appreciated

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-14 : 09:04:15
you mean automate script to be run in all client machines?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

emailuser
Yak Posting Veteran

74 Posts

Posted - 2011-09-14 : 09:17:15
Hi , not really automate , just want a sql script to connect , update and disconnect , with the information above, i will then call this script from the backup software as a post command ... hope that makes sense
Go to Top of Page

emailuser
Yak Posting Veteran

74 Posts

Posted - 2011-10-04 : 06:05:12
Hi .. anyone able to point me in the right direction , just looking how to do a simple script to update a database table that can be started from a users pc
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-04 : 06:22:42
quote:
Originally posted by emailuser

Hi .. anyone able to point me in the right direction , just looking how to do a simple script to update a database table that can be started from a users pc


shouldnt it be a simple update statement then?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

emailuser
Yak Posting Veteran

74 Posts

Posted - 2011-10-04 : 07:25:45
i guess i see the stages like this

1 Make connection to database with username and password
2 Update table ( i would need to pass the users logon name )
3 Disconnect

can this all be rolled into one statement ? , how would i capture the users logon name ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-04 : 08:01:08
quote:
Originally posted by emailuser

i guess i see the stages like this

1 Make connection to database with username and password
2 Update table ( i would need to pass the users logon name )
3 Disconnect

can this all be rolled into one statement ? , how would i capture the users logon name ?


you can connect from client by loggin on to sql management studio
the run your query and disconnect from ssms

or was your question even to automate that?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-10-04 : 08:25:46
Could run OSQL from the command line? (is it still called that?)
Go to Top of Page

emailuser
Yak Posting Veteran

74 Posts

Posted - 2011-10-04 : 08:55:02
Hi Visakh16 , the scenario is that i want to have this batch file on everyones desktop / laptop, once the backup software completes i want the script to run as said earlier , it should connect to the database update a table with username , todays date and a status flag , then disconnect, the idea being is that we then have a table which shows us who has backed up their data ,and when it happened .. howp that makes sense
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-10-04 : 09:03:32
You can run an OSQL command from a batch file. That can conenct to the database and update the user's logon time etc.

(Provided its still called "OSQL" these days)
Go to Top of Page
   

- Advertisement -