Syntax to call a t-sql script from another t-sql script

I need to know how to call a t-sql script from another t-sql script.

In Oracle I can add a line: @tce_load_company.sql to a sql command file, and it
will run that file. This allows me to have a single "master" file that has all
of my lower level table initialization values. What is the syntax for doing this
in SQLServer?

Thanks,

Chris Emerson


0
Christopher
11/3/2000 9:25:53 PM
sybase.sqlserver.general 4269 articles. 0 followers. Follow

3 Replies
1378 Views

Similar Articles

[PageSpeed] 43


"Christopher A. Emerson" wrote:

> I need to know how to call a t-sql script from another t-sql script.
>
> In Oracle I can add a line: @tce_load_company.sql to a sql command file, and it
> will run that file. This allows me to have a single "master" file that has all
> of my lower level table initialization values. What is the syntax for doing this
> in SQLServer?

There is nothing of the sort in the Server, but the isql client does
support an associated editor, and the ":r <filename>" command
will read in a script file. That would be the closest thing I can think of.

-bret

0
Bret
11/3/2000 10:30:59 PM
You can always build a stored procedure from the second set of
TSQL statements and call the proc from within the first TSQL
script.
Obviuosly, you can call a number of TSQL scripts from within a shell
script or perl or batch job.
0
Anonymous
11/4/2000 5:06:37 PM
One way you could do it is by shelling out from within the ISQL script and 
invoking another instance of isql. Two exclmation marks (!!) at the 
beginning of a command line in isql will run a shell command.

for example, you could create a sql script like the following:

--------------------------
create table ....
go
!! isql -Usa -P -Sservername -i script.sql 
....

--------------------------

-Ray Rankins
Gotham Consulting Services
2 Moonglow Rd.
Gansevoort, NY 12831
0
rrankins
11/7/2000 9:26:41 PM
Reply:

Similar Artilces:

calling a sql script from another sql script
Hi, does anyone know how to call a sql script (Note: not a stored procedure) from another sql script in sybase? In oracle, you just put @ before the script name. I haven't been able to find out how to do it in sybase. Any help will be greatly appreciated. -Yilin Yilin Cai wrote: > > Hi, does anyone know how to call a sql script (Note: not a stored > procedure) from > another sql script in sybase? In oracle, you just put @ before the > script name. > I haven't been able to find out how to do it in sybase. Any help will be > greatly > app...

ASA T-SQL vs MS T-SQL
Does anyone have/know of a list of points that present the differences between Sybase Adaptive Server Anywhere Transact SQL and Microsoft's T-SQL? This information would be used for porting some MS T-SQL to a SQL Anywhere 7 database. >Does anyone have/know of a list of points that present the differences >between Sybase Adaptive Server Anywhere Transact SQL and Microsoft's >T-SQL? >This information would be used for porting some MS T-SQL to a SQL >Anywhere 7 database. The ASA online help has an lengthy section on ASA (watcom) sql to T-SQL compatabili...

Documentation
Hi, I am using SQL Any for many years now (since the good old Watcom times) and it is a great (if not the best) DB server money can buy. I was also using MS SQL for quite a long time. I used to write mainly in T-SQL (because of compatibility with M$ SQL and ASE) but because of the much more powerfull language I use more and more Watcom SQL. However it would be a great help for me, to have a Watcom and T-SQL syntax displayed on the same help page. I could imagine somewhat similar to the help Microsoft provides in their SDK/API help. You can select the language on top (e.g. C...

T-SQL Script Confusion
Hi All, I am trying to create a database on a daily naming scheme. EXAMPLE: --PRINT datename(WeekDay,GetDate()) DECLARE @DBDATE varchar(50) SET @DBDATE = datename(WeekDay,GetDate()) -- the error message is tied to the line below CREATE DATABASE DATABASE_PRACTICE_+ @DBDATE error message is: Server: Msg 170, Level 15, State 1, Line 7 Line 7: Incorrect syntax near '+'. What the heck am I doing wrong?? Thanks Tony DECLARE @DbName NVARCHAR(50) SET @DbName = datename(WeekDay,GetDate()) SET @DbName = 'CREATE DATABASE DATABASE_PRACTICE_' + @DbName E...

T-SQL script through ISQL
I'm trying to run an ASE T-SQL script in ASA. In theory they're completely compatible, no ;-) My problem seems to be something simple with the 'go's being converted to semi-colons. Each individual statement works fine on its own, but when I try to run the script all at once, I get ASA Error -131 : Syntax error near ';' My workaround is to run every statement one at a time... it works, but it's not practical as a long term solution. Is anyone familiar with this phenomonon? What can I do to get around it? Thanks in advance, Matt script snip...

executing T sql function in Powerbuilder Script
Hi Group, I have to execute a sql statement which includes variable and T-Sql function. Below is the code. ls_sql = "INSERT INTO security..userworkgroup " + & "SELECT MAX(userworkgroupid) + 1, :al_userid , :al_workgroupid, getdate(), suser_name(), getdate(), suser_name(), 'ips_test'" +& " FROM security..userworkgroup" ll_rc = gnv_appmgr.itr_trans.of_execute(ls_sql) In the above sql :al_userid and al_workgroupid is the variable and suser_name() and getdate() is the function. I am getting error stating "Incorrect Syntax near :&q...

PL/SQL to T/SQL
Is there easy way of converting some of the oracle analytics queries to sybase. [code] SELECT MEMBER_KEY, ELIG_TYPE, PROD_CATEGORY, PLAN_ID, EFFECTIVE_DT, UPDATE_DT FROM ( SELECT MEMBER_KEY, ELIG_TYPE, PROD_CATEGORY, PLAN_ID, EFFECTIVE_DT, UPDATE_DT, dense_rank() over ( PARTITION BY events.MEMBER_KEY ORDER BY events.EFFECTIVE_DT DESC ) score ...

T-SQL and SQL 2005
What is the difference between T-SQL and normal SQL??RoelRoel Alblas, Dordrecht, Holland,www.gps2sms.nl Hi, from: http://en.wikipedia.org/wiki/TSQL Sometimes abbreviated T-SQL, Transact-SQL is Microsoft's and Sybase's proprietary extension to the SQL language. Microsoft's implementation ships in the Microsoft SQL Server product. Sybase uses the language in its Adaptive Server Enterprise, the successor to Sybase SQL Server. In order to make it more powerful, SQL has been enhanced with additional features such as: Control-of-flow language Local variables User authentication integrat...

difference between T-Sql and Sql,
Hi guys, I am very new to Sybase, can some one tell me the differences between T-Sql and Sql. Thanks in advance, Munish. I believe you are referring to: SQL--The standard SQL syntax used universally for most DBMS's T-SQL--Transact-SQL, Sybase's flavor of SQL the is used for writing stored proc's, etc. I supported variable declarations, functions and data-type conversion. -Dan ...

Script called by another script
Hello, I'm trying to launch a script from another script: ----- script1.js ----- Packages.java; importPackage(java.lang); importPackage(Packages.org.mozilla.javascript); var scope = Context.enter().initStandardObjects(); Context.enter().evaluateReader(scope, new FileReader("script2.js"), "script2.js", 1, null); ------ script2.js ----- Packages.java; importPackage(java.lang); ----> an exception occurs : js: "script2.js", line 2: uncaught JavaScript runtime exception: ReferenceError: "importPackage" is not define.. ...

GENERAL SQL SERVER: Question about the Script that setups the SQL Server Database.
This is the first time I have created a script for Sql Server 2000, and I have run into a few syntax ereas that I am not familar with. Bellow is a section of the script from the Portal server packages. At the end of the sample, is "ON [PRIMARY], Can anyone explain to me what this does and why the primary key isnt setup inside the code itself? I am basically trying to take parts of the script and incorrporate it into my own script and hate added syntax that I dont understand, makes debugging a real pain in the future. CREATE TABLE [dbo].[Portal_Announcements] ( [ItemID] [in...

How to write triger using T-SQL, & where get info about using T-SQL in ASA
Hello I want to have last update date of the row in table field "RecUpdateDate", when record is updated. How to write ASA triger using T-SQL . Something like this(this trigger updates record with ID =1): create trigger DBA.tr_test_iu on dba.test for insert,update as begin update dba.test set RecUpdateDate = GETDATE(*) where ID = 1 end Using WatcomSQL I can do this using "reference" Thanks -- Linas Kavolius Instead of writing a trigger to do this, define the column as: last_modified timestamp not null default times...

sql script doesn't create sprocs or tables
Hi, they don't exactly make it easy to install this app block. When I start the app and click on a button, I get the error: " could not find the sproc" yet, I ran the 2 sql setup files w/out a problem.I do notice that there are no sprocs or user tables in the database though. Does anyone know what could have caused this? cheers, yogi.buy an old van and drive round oz....

Calling .sql scripts
I'm trying to figure out how to call a sql script from another sql script. For some reason I can't find any info. In oracle it is quite simple, just do this @create_oracle_tables_1.sql @create_oracle_tables_2.sql commit; Any help would be appreciated Fred Just execute the read command from a .SQL script top.sql contains : read sql1.sql read sql2.sql sql1.sql contains : message 'sql1'; sql2.sql contains : message 'sql2'; -- Reg Domaratzki Sybase iAnywhere Solutions Please reply only to the newsgroup ASA Patches and EBFs : htt...

Web resources about - Syntax to call a t-sql script from another t-sql script - sybase.sqlserver.general

Taylor Swift’s 1989 World Tour Documentary Now Live On Apple Music
One of the biggest international pop stars the world has ever seen recently announced a new deal with Apple, Taylor Swift herself confirmed a ...

Lebanese militant leader killed in Israeli raid in Syria
By Mariam Karouny and Suleiman Al-Khalidi BEIRUT (Reuters) - An Israeli air strike killed Samir Qantar, a Hezbollah militant leader, in Damascus ...

Air France bomb scare on plane to Paris was a false alarm, says chief executive - World news - The Guardian ...
Suspicious device discovered in flight AF463’s lavatory forced jet to make emergency landing in Mombasa

Auburn Deputy Mayor Salim Mehajer to be charged with electoral fraud offences
Controversial Auburn City Council Deputy Mayor Salim Mehajer is served with a court attendance notice for alleged electoral fraud offences.

Landslide buries buildings in southern China; 27 missing
Fox News Landslide buries buildings in southern China; 27 missing Fox News BEIJING – A landslide collapsed and buried buildings at and around ...

Terrorist Tashfeen Malik’s Visa Application ‘Sloppily Handled:’ Congressman
Tashfeen Malik, one of the terrorists in the San Bernardino shooting, got into the U.S. partially thanks to a “sloppily handled” visa application, ...

The Latest: Podemos party leader hails 'historic' Spain vote
MADRID (AP) — The latest developments on Spain's general election. All times local.

Police Shooting Cases Hang Over Cincinnati and Cleveland
Volatile, racially charged police shooting cases hang over Cincinnati, Cleveland

'Remember his name': Knoxville teen killed by gunfire praised for sacrifice
Knoxville News Sentinel 'Remember his name': Knoxville teen killed by gunfire praised for sacrifice Knoxville News Sentinel Zack Dobson, bottom ...

South China Sea- Other countries shouldn’t meddle: Chinese envoy
BJP general secretary Ram Madhav and Chinese ambassador Le Yucheng shared opposing views on the contentious issue of South China Sea on Saturday. ...

Resources last updated: 12/20/2015 4:55:59 PM