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.
Author |
Topic |
rcjay272
Starting Member
1 Post |
Posted - 2013-01-12 : 12:53:05
|
All,I am new to creating scripts to run on SQL. My goal is to create a script that allows me to query one table for an "id" value and then run a delete statement on another table to delete a row.These are the SQL commands I run manually and I would like to automate this so I don't have to get into SQL MGMT Studio each time.select id from user where uName='johndoe'Output09123a6bDelete from othertable where uid='09123a6b'However.....I want to script this so I can run it like a batch file with a variable. Is this possible? Where do I start?I would like something like this....this is just an example of how I think it should work.c:\deleteuser.bat johndoeThank you,Rob |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-12 : 13:39:05
|
just make script like procedure as below[code]CREATE PROC DeleteUserDetails@User varchar(100)ASDelete from othertable ojoin user uon u.id = o.uidwhere u.uName=@UserGOthen call it from automated job as EXEC DeleteUserDetails 'johndoe'------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|