March 14, 2012 at 2:05 am
Hi all,
I have the follwing Code in a .sql file
Declare @SQLStmt varchar(max)
set @SQLStmt='insert into sa(last,first)values(1,2)'
exec(@SQLStmt)
The Requirement is as soon as I double click on this SQL file , it should insert a row in my table "SS" without clicking on the Execute button. Can any one tell me how can I achieve this?
March 14, 2012 at 2:28 am
you would need to create a batch file which calls SQLCMD passing in the .sql file and then run the batch file, the only way in SSMS is to press F5 or the execute button
March 14, 2012 at 2:32 am
Create .bat file:
sqlcmd -S ServerName -E -d DatabaseName -Q "insert into sa(last,first)values(1,2)"
March 14, 2012 at 3:01 am
Thank you all for the replies..It worked..
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply