Anyone have any ideas on how to use a stored procedure to update multiple tables simultaneously? I am updating a parent record and zero or more child records. I would like to make one stored procedure call if possible to do so. Any ideas on doing this would be appreciated. Thanks!
EverettYou can update more than one table within a stored procedure, just make sure to use BEGIN TRAN/COMMIT TRAN/ROLLBACK TRAN
Example:
CREATE PROCEDURE sp_ModifyMasterDetail
(
.
.
.
@.msg varchar(255) output
)
AS
SET NOCOUNT ON
DECLARE @.error int
, @.tfTran tinyint
--
-- Start Transaction
--
IF (@.@.TRANCOUNT = 0) BEGIN
SELECT @.tfTran = 1
BEGIN TRAN
END
ELSE
SELECT @.tfTran = 0
UPDATE tblMaster
.
WHERE ID = @.ID
SELECT @.error = @.@.error
IF (@.error <> 0)
GOTO Error_Exit
UPDATE tblDetail
.
WHERE ID = @.ID
AND SubID = @.SubID
SELECT @.error = @.@.error
IF (@.error <> 0)
GOTO Error_Exit
--
-- Check to see if an error occured during processing. If so then
-- ROLLBACK else COMMIT transactions
--
Error_Exit:
IF (@.error <> 0) BEGIN
IF (@.tfTran = 1)
ROLLBACK TRAN
SELECT @.msg = 'ERROR: Transaction failed with error ' + CONVERT(varchar(20),@.error),
END
ELSE BEGIN
IF (@.tfTran = 1)
COMMIT TRAN
SELECT @.msg = 'Transaction successful'
END
RETURN @.error
GO|||begin tran
update parent set ...
if @.@.error <> 0
begin
raiserror('failed',16,-1)
rollback tran
return
end
update child set ...
if @.@.error <> 0
begin
raiserror('failed',16,-1)
rollback tran
return
end
commit tran
Or you could put a trigger on the parent (or child) table or on a view of the combination - depends on the updates you want to do.|||Thanks guys! Either one of these will do the trick, except that I'm not sure how to get the data into the stored procedure! I guess I could munge it into varchar(8000), but I'm not sure that it would always be long enough. Any way of passing either an array or a recordset/cursor into a stored procedure?
Everett|||You can create a temp table on the spid, populate it then access it in the SP.
Call the SP repeated times with the values and the SP can populate a table keyed on spid.
Call the sp with comma delimitted strings with the values.
Have lots of parameters - up to the max you think you will need.
Showing posts with label multiple. Show all posts
Showing posts with label multiple. Show all posts
Tuesday, March 27, 2012
Monday, March 19, 2012
A table within a table
Does anyone know how to put a table within a table? I need to use
multiple datasets within one table, but since it will only let me put
one dataset within the table, I am trying to put a table within a table
but I can't get it to work. Thank you for any help that you can give!What are you trying to accomplish? Maybe there's another way...
"KimB" wrote:
> Does anyone know how to put a table within a table? I need to use
> multiple datasets within one table, but since it will only let me put
> one dataset within the table, I am trying to put a table within a table
> but I can't get it to work. Thank you for any help that you can give!
>|||Hi! Actually, the stored procedures were already given to me and I have two
rows to put in my report, with row one coming from one procedure, and row two
coming from the other procedure. I did try putting a list within the table
and the list let me use a different data set than the table was...I know
that the table within a table should let me use different data sets, but I
havent been able to figure it out. Thank you for responding!
"daw" wrote:
> What are you trying to accomplish? Maybe there's another way...
> "KimB" wrote:
> > Does anyone know how to put a table within a table? I need to use
> > multiple datasets within one table, but since it will only let me put
> > one dataset within the table, I am trying to put a table within a table
> > but I can't get it to work. Thank you for any help that you can give!
> >
> >|||I haven't really used temp tables, but could you combine the data from the
two stored procedures into a temp table and use that as your data set?
"KimB" wrote:
> Hi! Actually, the stored procedures were already given to me and I have two
> rows to put in my report, with row one coming from one procedure, and row two
> coming from the other procedure. I did try putting a list within the table
> and the list let me use a different data set than the table was...I know
> that the table within a table should let me use different data sets, but I
> havent been able to figure it out. Thank you for responding!
> "daw" wrote:
> > What are you trying to accomplish? Maybe there's another way...
> >
> > "KimB" wrote:
> >
> > > Does anyone know how to put a table within a table? I need to use
> > > multiple datasets within one table, but since it will only let me put
> > > one dataset within the table, I am trying to put a table within a table
> > > but I can't get it to work. Thank you for any help that you can give!
> > >
> > >|||I have the same problem too, the only difference is I have 20 stored
procedures to call for my 20 different tables.
"daw" wrote:
> I haven't really used temp tables, but could you combine the data from the
> two stored procedures into a temp table and use that as your data set?
> "KimB" wrote:
> > Hi! Actually, the stored procedures were already given to me and I have two
> > rows to put in my report, with row one coming from one procedure, and row two
> > coming from the other procedure. I did try putting a list within the table
> > and the list let me use a different data set than the table was...I know
> > that the table within a table should let me use different data sets, but I
> > havent been able to figure it out. Thank you for responding!
> >
> > "daw" wrote:
> >
> > > What are you trying to accomplish? Maybe there's another way...
> > >
> > > "KimB" wrote:
> > >
> > > > Does anyone know how to put a table within a table? I need to use
> > > > multiple datasets within one table, but since it will only let me put
> > > > one dataset within the table, I am trying to put a table within a table
> > > > but I can't get it to work. Thank you for any help that you can give!
> > > >
> > > >
multiple datasets within one table, but since it will only let me put
one dataset within the table, I am trying to put a table within a table
but I can't get it to work. Thank you for any help that you can give!What are you trying to accomplish? Maybe there's another way...
"KimB" wrote:
> Does anyone know how to put a table within a table? I need to use
> multiple datasets within one table, but since it will only let me put
> one dataset within the table, I am trying to put a table within a table
> but I can't get it to work. Thank you for any help that you can give!
>|||Hi! Actually, the stored procedures were already given to me and I have two
rows to put in my report, with row one coming from one procedure, and row two
coming from the other procedure. I did try putting a list within the table
and the list let me use a different data set than the table was...I know
that the table within a table should let me use different data sets, but I
havent been able to figure it out. Thank you for responding!
"daw" wrote:
> What are you trying to accomplish? Maybe there's another way...
> "KimB" wrote:
> > Does anyone know how to put a table within a table? I need to use
> > multiple datasets within one table, but since it will only let me put
> > one dataset within the table, I am trying to put a table within a table
> > but I can't get it to work. Thank you for any help that you can give!
> >
> >|||I haven't really used temp tables, but could you combine the data from the
two stored procedures into a temp table and use that as your data set?
"KimB" wrote:
> Hi! Actually, the stored procedures were already given to me and I have two
> rows to put in my report, with row one coming from one procedure, and row two
> coming from the other procedure. I did try putting a list within the table
> and the list let me use a different data set than the table was...I know
> that the table within a table should let me use different data sets, but I
> havent been able to figure it out. Thank you for responding!
> "daw" wrote:
> > What are you trying to accomplish? Maybe there's another way...
> >
> > "KimB" wrote:
> >
> > > Does anyone know how to put a table within a table? I need to use
> > > multiple datasets within one table, but since it will only let me put
> > > one dataset within the table, I am trying to put a table within a table
> > > but I can't get it to work. Thank you for any help that you can give!
> > >
> > >|||I have the same problem too, the only difference is I have 20 stored
procedures to call for my 20 different tables.
"daw" wrote:
> I haven't really used temp tables, but could you combine the data from the
> two stored procedures into a temp table and use that as your data set?
> "KimB" wrote:
> > Hi! Actually, the stored procedures were already given to me and I have two
> > rows to put in my report, with row one coming from one procedure, and row two
> > coming from the other procedure. I did try putting a list within the table
> > and the list let me use a different data set than the table was...I know
> > that the table within a table should let me use different data sets, but I
> > havent been able to figure it out. Thank you for responding!
> >
> > "daw" wrote:
> >
> > > What are you trying to accomplish? Maybe there's another way...
> > >
> > > "KimB" wrote:
> > >
> > > > Does anyone know how to put a table within a table? I need to use
> > > > multiple datasets within one table, but since it will only let me put
> > > > one dataset within the table, I am trying to put a table within a table
> > > > but I can't get it to work. Thank you for any help that you can give!
> > > >
> > > >
Friday, February 24, 2012
A question about Create Schema in SQL Server
Hi there,
I've a question regarding Schema in SQLServer. If i compare with Oracle, in
Oracle there is an option to create multiple "Tablespaces" in ONE single dat
abase instance. When a database user is created, it needs to be assigned a s
pecific tablespace. Now whe
n user actually logs in, a new "Schema" is created with the same name as Use
rname in the tablespace assigned and all the operations are performed in thi
s user specific schema.
The advantage is here that in ONE database instance, multiple schemas can be
created each of them having same set of tables, views etc. And a specifc us
er per schema is having access to all objects created in Schema.
I wonder does MSSQL server 2000 has something like this? I see a "Create Sch
ema" option but the documentation did not help me.
I would appreciate if one can help with this scenario. The objective is that
in ONE single database instance SHOULD HAVE multile SCHEMAS with identical
objects (tables, views etc).
Thanks in advanceThe schema concept does not exist, per se, in 2000. But you will be able to
do something like this in SQL Server 2005.
http://www.aspfaq.com/
(Reverse address to reply.)
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>|||> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
As Aaron mentioned, SQL 2005 will extent this functionality. However, you
can have multiple schema in a single database and/or single instance in all
versions of SQL Server. The script below illustrates how one can do this in
a single database. If you need to isolate default physical object placement
(akin to default tablespace), you can use separate databases within the same
instance. Unlike Oracle, you can have multiple databases per SQL Server
instance.
USE MyDatabase
EXEC sp_addlogin 'Schema1'
EXEC sp_addlogin 'Schema2'
EXEC sp_adduser 'Schema1'
EXEC sp_adduser 'Schema2'
CREATE TABLE Schema1.Table1(Col1 int)
CREATE TABLE Schema2.Table1(Col1 int)
Hope this helps.
Dan Guzman
SQL Server MVP
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>
I've a question regarding Schema in SQLServer. If i compare with Oracle, in
Oracle there is an option to create multiple "Tablespaces" in ONE single dat
abase instance. When a database user is created, it needs to be assigned a s
pecific tablespace. Now whe
n user actually logs in, a new "Schema" is created with the same name as Use
rname in the tablespace assigned and all the operations are performed in thi
s user specific schema.
The advantage is here that in ONE database instance, multiple schemas can be
created each of them having same set of tables, views etc. And a specifc us
er per schema is having access to all objects created in Schema.
I wonder does MSSQL server 2000 has something like this? I see a "Create Sch
ema" option but the documentation did not help me.
I would appreciate if one can help with this scenario. The objective is that
in ONE single database instance SHOULD HAVE multile SCHEMAS with identical
objects (tables, views etc).
Thanks in advanceThe schema concept does not exist, per se, in 2000. But you will be able to
do something like this in SQL Server 2005.
http://www.aspfaq.com/
(Reverse address to reply.)
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>|||> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
As Aaron mentioned, SQL 2005 will extent this functionality. However, you
can have multiple schema in a single database and/or single instance in all
versions of SQL Server. The script below illustrates how one can do this in
a single database. If you need to isolate default physical object placement
(akin to default tablespace), you can use separate databases within the same
instance. Unlike Oracle, you can have multiple databases per SQL Server
instance.
USE MyDatabase
EXEC sp_addlogin 'Schema1'
EXEC sp_addlogin 'Schema2'
EXEC sp_adduser 'Schema1'
EXEC sp_adduser 'Schema2'
CREATE TABLE Schema1.Table1(Col1 int)
CREATE TABLE Schema2.Table1(Col1 int)
Hope this helps.
Dan Guzman
SQL Server MVP
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>
A question about Create Schema in SQL Server
Hi there,
I've a question regarding Schema in SQLServer. If i compare with Oracle, in Oracle there is an option to create multiple "Tablespaces" in ONE single database instance. When a database user is created, it needs to be assigned a specific tablespace. Now whe
n user actually logs in, a new "Schema" is created with the same name as Username in the tablespace assigned and all the operations are performed in this user specific schema.
The advantage is here that in ONE database instance, multiple schemas can be created each of them having same set of tables, views etc. And a specifc user per schema is having access to all objects created in Schema.
I wonder does MSSQL server 2000 has something like this? I see a "Create Schema" option but the documentation did not help me.
I would appreciate if one can help with this scenario. The objective is that in ONE single database instance SHOULD HAVE multile SCHEMAS with identical objects (tables, views etc).
Thanks in advance
The schema concept does not exist, per se, in 2000. But you will be able to
do something like this in SQL Server 2005.
http://www.aspfaq.com/
(Reverse address to reply.)
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>
|||> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
As Aaron mentioned, SQL 2005 will extent this functionality. However, you
can have multiple schema in a single database and/or single instance in all
versions of SQL Server. The script below illustrates how one can do this in
a single database. If you need to isolate default physical object placement
(akin to default tablespace), you can use separate databases within the same
instance. Unlike Oracle, you can have multiple databases per SQL Server
instance.
USE MyDatabase
EXEC sp_addlogin 'Schema1'
EXEC sp_addlogin 'Schema2'
EXEC sp_adduser 'Schema1'
EXEC sp_adduser 'Schema2'
CREATE TABLE Schema1.Table1(Col1 int)
CREATE TABLE Schema2.Table1(Col1 int)
Hope this helps.
Dan Guzman
SQL Server MVP
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>
I've a question regarding Schema in SQLServer. If i compare with Oracle, in Oracle there is an option to create multiple "Tablespaces" in ONE single database instance. When a database user is created, it needs to be assigned a specific tablespace. Now whe
n user actually logs in, a new "Schema" is created with the same name as Username in the tablespace assigned and all the operations are performed in this user specific schema.
The advantage is here that in ONE database instance, multiple schemas can be created each of them having same set of tables, views etc. And a specifc user per schema is having access to all objects created in Schema.
I wonder does MSSQL server 2000 has something like this? I see a "Create Schema" option but the documentation did not help me.
I would appreciate if one can help with this scenario. The objective is that in ONE single database instance SHOULD HAVE multile SCHEMAS with identical objects (tables, views etc).
Thanks in advance
The schema concept does not exist, per se, in 2000. But you will be able to
do something like this in SQL Server 2005.
http://www.aspfaq.com/
(Reverse address to reply.)
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>
|||> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
As Aaron mentioned, SQL 2005 will extent this functionality. However, you
can have multiple schema in a single database and/or single instance in all
versions of SQL Server. The script below illustrates how one can do this in
a single database. If you need to isolate default physical object placement
(akin to default tablespace), you can use separate databases within the same
instance. Unlike Oracle, you can have multiple databases per SQL Server
instance.
USE MyDatabase
EXEC sp_addlogin 'Schema1'
EXEC sp_addlogin 'Schema2'
EXEC sp_adduser 'Schema1'
EXEC sp_adduser 'Schema2'
CREATE TABLE Schema1.Table1(Col1 int)
CREATE TABLE Schema2.Table1(Col1 int)
Hope this helps.
Dan Guzman
SQL Server MVP
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>
A question about Create Schema in SQL Server
Hi there,
I've a question regarding Schema in SQLServer. If i compare with Oracle, in Oracle there is an option to create multiple "Tablespaces" in ONE single database instance. When a database user is created, it needs to be assigned a specific tablespace. Now when user actually logs in, a new "Schema" is created with the same name as Username in the tablespace assigned and all the operations are performed in this user specific schema.
The advantage is here that in ONE database instance, multiple schemas can be created each of them having same set of tables, views etc. And a specifc user per schema is having access to all objects created in Schema.
I wonder does MSSQL server 2000 has something like this? I see a "Create Schema" option but the documentation did not help me.
I would appreciate if one can help with this scenario. The objective is that in ONE single database instance SHOULD HAVE multile SCHEMAS with identical objects (tables, views etc).
Thanks in advanceThe schema concept does not exist, per se, in 2000. But you will be able to
do something like this in SQL Server 2005.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>|||> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
As Aaron mentioned, SQL 2005 will extent this functionality. However, you
can have multiple schema in a single database and/or single instance in all
versions of SQL Server. The script below illustrates how one can do this in
a single database. If you need to isolate default physical object placement
(akin to default tablespace), you can use separate databases within the same
instance. Unlike Oracle, you can have multiple databases per SQL Server
instance.
USE MyDatabase
EXEC sp_addlogin 'Schema1'
EXEC sp_addlogin 'Schema2'
EXEC sp_adduser 'Schema1'
EXEC sp_adduser 'Schema2'
CREATE TABLE Schema1.Table1(Col1 int)
CREATE TABLE Schema2.Table1(Col1 int)
--
Hope this helps.
Dan Guzman
SQL Server MVP
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>
I've a question regarding Schema in SQLServer. If i compare with Oracle, in Oracle there is an option to create multiple "Tablespaces" in ONE single database instance. When a database user is created, it needs to be assigned a specific tablespace. Now when user actually logs in, a new "Schema" is created with the same name as Username in the tablespace assigned and all the operations are performed in this user specific schema.
The advantage is here that in ONE database instance, multiple schemas can be created each of them having same set of tables, views etc. And a specifc user per schema is having access to all objects created in Schema.
I wonder does MSSQL server 2000 has something like this? I see a "Create Schema" option but the documentation did not help me.
I would appreciate if one can help with this scenario. The objective is that in ONE single database instance SHOULD HAVE multile SCHEMAS with identical objects (tables, views etc).
Thanks in advanceThe schema concept does not exist, per se, in 2000. But you will be able to
do something like this in SQL Server 2005.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>|||> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
As Aaron mentioned, SQL 2005 will extent this functionality. However, you
can have multiple schema in a single database and/or single instance in all
versions of SQL Server. The script below illustrates how one can do this in
a single database. If you need to isolate default physical object placement
(akin to default tablespace), you can use separate databases within the same
instance. Unlike Oracle, you can have multiple databases per SQL Server
instance.
USE MyDatabase
EXEC sp_addlogin 'Schema1'
EXEC sp_addlogin 'Schema2'
EXEC sp_adduser 'Schema1'
EXEC sp_adduser 'Schema2'
CREATE TABLE Schema1.Table1(Col1 int)
CREATE TABLE Schema2.Table1(Col1 int)
--
Hope this helps.
Dan Guzman
SQL Server MVP
"HV" <HV@.discussions.microsoft.com> wrote in message
news:3962090B-2595-43A0-A148-D57CA6799F51@.microsoft.com...
> Hi there,
> I've a question regarding Schema in SQLServer. If i compare with Oracle,
in Oracle there is an option to create multiple "Tablespaces" in ONE single
database instance. When a database user is created, it needs to be assigned
a specific tablespace. Now when user actually logs in, a new "Schema" is
created with the same name as Username in the tablespace assigned and all
the operations are performed in this user specific schema.
> The advantage is here that in ONE database instance, multiple schemas can
be created each of them having same set of tables, views etc. And a specifc
user per schema is having access to all objects created in Schema.
> I wonder does MSSQL server 2000 has something like this? I see a "Create
Schema" option but the documentation did not help me.
> I would appreciate if one can help with this scenario. The objective is
that in ONE single database instance SHOULD HAVE multile SCHEMAS with
identical objects (tables, views etc).
> Thanks in advance
>
Subscribe to:
Posts (Atom)