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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 What wrong in my SQL command?

Author  Topic 

ultra2
Starting Member

2 Posts

Posted - 2006-01-20 : 03:07:29
Here is my command.

create proc file_path
as
declare @SeverPath varchar(50)
declare @DataPath varchar(50)
set @SeverPath ='C:\Sql\'
set @DataPath ='C:\Sql\'
go

-- SCRIPT: create database
exec file_path
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = 'WECON')
drop database WECON
go
create database WECON
on
( name = 'WECON_Dat',
filename = ServerPath + 'WECON_Dat.mdf',
size = 100MB,
maxsize = 200MB )
log on
( name = 'WECON_Log',
filename = ServerPath + 'WECON_Log.ldf',
size = 100MB,
maxsize = 200MB )
go

And here is the error msg. that i got.

Server: Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near '+'.

What wrong in my command?
Thanks in advance,

PS. I'm using MS SQL2000

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-20 : 03:21:44
ServerPath should be @ServerPath

Why do you create Database using Procedure?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-20 : 03:25:31
Your file_path SP is a bit weird. You declare 2 local variable, assign value to it and then do nothing about it.
Are you trying to do this ?
create proc file_path
@SeverPath varchar(50) OUTPUT,
@DataPath varchar(50) OUTPUT
as
begin
set @SeverPath ='C:\Sql\'
set @DataPath ='C:\Sql\'
end


-----------------
'KH'

Go to Top of Page

ultra2
Starting Member

2 Posts

Posted - 2006-01-20 : 04:01:16
Thanks for quick reply, both of you. I can correct my command by now.
However, I had another question to ask you all.

From my command below, I just want to know that can I used variable (@DataPath, @LogPath) in filename parameter?

create database WECON
on primary
( name = 'WECON_Dat',
filename = @DataPath,
size = 100MB,
maxsize = 200MB )
log on
( name = 'WECON_Log',
filename = @LogPath,
size = 100MB,
maxsize = 200MB )
go
Go to Top of Page
   

- Advertisement -