Tuesday, March 27, 2012
Are all indexes created on subscriber ?
clustered indexes are copied to the subscriber .. Can someone confirm ?
Hassan,
the settings on the snapshot properties tab of the article properties
determines which indexes are copied over. If any are created afterward
initialization, they'll not be replicated, so sp_addscriptexec can be used
for these.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
Archiving is Not reducing DB Size
but it looks like the DB size is not reducing!!! Some times it looks like the size has increased!!
I think this is because of the log file size has increaded by the DELETE operations...But what can I do for this?
Please Help!!Action\All Tasks\Shrink Database in EM
or
DBCC SHRINKDATABASE in QA
Monday, March 19, 2012
Applying of snapshot for transaction replication with DTS transfor
move all data from publisher to subscriber - apply snapshot to subscriber.
Subscriber have different schema but no data. How it is possible to do? I
expected snapshot will use same DTS, but it not use it. Publisher DB is 24/7
system.
Have a look at transformable subscriptions. I would also advise you to have
a look at custom sync objects and encapsulating the data mapping in the
replication stored procedures as opposed to use DTS transforms due to
performance reasons.
Here is an article explaining how to do this.
http://www.dbazine.com/sql/sql-artic...rm=replicating
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"andsm" <andsm@.discussions.microsoft.com> wrote in message
news:53CF05CA-FA93-4AAE-A4AA-37347B3060E7@.microsoft.com...
>I created transaction replication with DTS transformation. Next I want to
> move all data from publisher to subscriber - apply snapshot to subscriber.
> Subscriber have different schema but no data. How it is possible to do? I
> expected snapshot will use same DTS, but it not use it. Publisher DB is
> 24/7
> system.
applying dbo to all objects by default?
Is there a way to assign all objects being created to be assigned to DBO as
opposed to the person who is creating them?
We have some programmers who need db_owner access, and when they create a
new sp or table the objects are tied to them now. Can it by defaul be
assigned to DBO instead?
TIA,
ScottScott
They should specify a DBO user as
CREATE TABLE dbo.Test (col INT) and then the table will belong to the DBO
user
If you want the DBO to be created by default you should add them to
sysadmin server role
"Scott" <sfruhwirth@.gmail.com> wrote in message
news:OqYCpMXUFHA.612@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Is there a way to assign all objects being created to be assigned to DBO
as
> opposed to the person who is creating them?
> We have some programmers who need db_owner access, and when they create a
> new sp or table the objects are tied to them now. Can it by defaul be
> assigned to DBO instead?
> TIA,
> Scott
>
Wednesday, March 7, 2012
application role how query a view whose reference table is in another db?
Hi everybody.
I created an application role in a database (DB1) and gave it all the rights on a view in DB1 which refers to a table located in another db (DB2). I also gave the rights to the app role on a table of DB1
I tried to use this app. role through the sp_setapprole launched by a user (server principal?) which is SQL Server administrator (and local administrator (Win 2003 Server)).
With the following query
SELECT USER_NAME()
I see that the approle is being used.
Than, if I query the table on DB1 everything works, but if I query the view, referring a table in db2 I get following error:
The server principal "NameOfServerPrincipal" is not able to access the database "DB2" under the current security context.
What should I do to make it work?
The table in DB2 has the same schema of the view in DB1 which refers to it.
I put the DB1 TrustWorthy and both the database have the db_chaining option activated.
Any idea on how to solve the problem would be widely appreciated.
Thank you very much.
Vania
Application roles are not designed to work on cross-database scenarios. The following post has a detailed discussion on the topic: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1312863&SiteID=1
If your application relies heavily on cross-database access, I would recommend against using application roles. If you don’ have a choice, you can create a new execution context using EXECUTE AS in a SP. I wrote a small example that hopefully will be useful:
-- We will strat creating a low privielged login
--that will be used for the cross-DB context
-- and disable it to prevent any connection with it
--
CREATE LOGIN crossdb_login WITH PASSWORD = '50m3 p4zzwrd#'
ALTER LOGIN crossdb_login DISABLE
go
-- First we will go to our source DB to create the SP
-- and digitally sign it
--
use db_Source
go
CREATE USER crossdb_user FOR LOGIN crossdb_login
go
-- This SP will run under the 'crossdb_user' context
--
CREATE PROC sp_demo
WITH EXECUTE AS 'crossdb_user'
AS
-- display the token for testing purposes
SELECT * FROM db_Target.sys.user_token
-- select from a table
SELECT * FROM db_Target.dbo.data
go
-- Sign the modul and create a backup of the cert
-- in order to create a login for it
--
CREATE CERTIFICATE signing_cert
ENCRYPTION BY PASSWORD = '50m3 p4zzwrd#'
WITH SUBJECT = 'signing cert'
go
ADD SIGNATURE TO sp_demo
BY CERTIFICATE signing_cert
WITH PASSWORD = '50m3 p4zzwrd#'
go
BACKUP CERTIFICATE signing_cert TO FILE = 'signing_cert.cer'
go
-- Create a copy of the cert in master and a login mapped to it
--
USE master
go
CREATE CERTIFICATE signing_cert FROM FILE = 'signing_cert.cer'
go
CREATE LOGIN signing_cert FROM CERTIFICATE signing_cert
go
-- Now in the target DB we will create the user we need
-- and grant the appropriate permissions
--
use db_Target
go
CREATE TABLE data( value int )
go
CREATE USER crossdb_user FOR LOGIN crossdb_login
CREATE USER signing_cert
go
-- The certificate will be used to vouch for the
-- impersonated context
--
GRANT AUTHENTICATE TO signing_cert
go
-- GRANT SELECT on the table to the impersonated context
--
GRANT SELECT ON dbo.data to crossdb_user
go
-- Test the new signed SP
--
use db_Source
go
CREATE APPLICATION ROLE approle_demo WITH PASSWORD = '@.ppr0l3 d3m00'
go
GRANT EXECUTE ON sp_demo to approle_demo
go
EXEC sp_setapprole 'approle_demo', '@.ppr0l3 d3m00'
go
-- Should fail
-- Msg 916, Level 14, State 1, Line 1
-- The server principal "<<login_name>>" is not able to access the database "db_Target" under the current security context.
--
SELECT * FROM db_Target.dbo.data
go
-- Should succeed
EXEC sp_demo
go
Please let us know if you have any questions.
Thanks,
-Raul Garcia
SDE/T
SQL Server Engine
|||
Thank you so much and forgive me for my late but was on holidays.
Your solution works fine, in fact (I am sure you have no doubts about it).
A more question, please forgive me if it is obvious:
how, from inside the sp_demo, can I get the name of the server principal (domain\user if Windows authentication) which set the application role ? I mean the caller of the setapprole.
Thank you very much.
Vania
application role how query a view whose reference table is in another db?
Hi everybody.
I created an application role in a database (DB1) and gave it all the rights on a view in DB1 which refers to a table located in another db (DB2). I also gave the rights to the app role on a table of DB1
I tried to use this app. role through the sp_setapprole launched by a user (server principal?) which is SQL Server administrator (and local administrator (Win 2003 Server)).
With the following query
SELECT USER_NAME()
I see that the approle is being used.
Than, if I query the table on DB1 everything works, but if I query the view, referring a table in db2 I get following error:
The server principal "NameOfServerPrincipal" is not able to access the database "DB2" under the current security context.
What should I do to make it work?
The table in DB2 has the same schema of the view in DB1 which refers to it.
I put the DB1 TrustWorthy and both the database have the db_chaining option activated.
Any idea on how to solve the problem would be widely appreciated.
Thank you very much.
Vania
Application roles are not designed to work on cross-database scenarios. The following post has a detailed discussion on the topic: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1312863&SiteID=1
If your application relies heavily on cross-database access, I would recommend against using application roles. If you don’ have a choice, you can create a new execution context using EXECUTE AS in a SP. I wrote a small example that hopefully will be useful:
-- We will strat creating a low privielged login
--that will be used for the cross-DB context
-- and disable it to prevent any connection with it
--
CREATE LOGIN crossdb_login WITH PASSWORD = '50m3 p4zzwrd#'
ALTER LOGIN crossdb_login DISABLE
go
-- First we will go to our source DB to create the SP
-- and digitally sign it
--
use db_Source
go
CREATE USER crossdb_user FOR LOGIN crossdb_login
go
-- This SP will run under the 'crossdb_user' context
--
CREATE PROC sp_demo
WITH EXECUTE AS 'crossdb_user'
AS
-- display the token for testing purposes
SELECT * FROM db_Target.sys.user_token
-- select from a table
SELECT * FROM db_Target.dbo.data
go
-- Sign the modul and create a backup of the cert
-- in order to create a login for it
--
CREATE CERTIFICATE signing_cert
ENCRYPTION BY PASSWORD = '50m3 p4zzwrd#'
WITH SUBJECT = 'signing cert'
go
ADD SIGNATURE TO sp_demo
BY CERTIFICATE signing_cert
WITH PASSWORD = '50m3 p4zzwrd#'
go
BACKUP CERTIFICATE signing_cert TO FILE = 'signing_cert.cer'
go
-- Create a copy of the cert in master and a login mapped to it
--
USE master
go
CREATE CERTIFICATE signing_cert FROM FILE = 'signing_cert.cer'
go
CREATE LOGIN signing_cert FROM CERTIFICATE signing_cert
go
-- Now in the target DB we will create the user we need
-- and grant the appropriate permissions
--
use db_Target
go
CREATE TABLE data( value int )
go
CREATE USER crossdb_user FOR LOGIN crossdb_login
CREATE USER signing_cert
go
-- The certificate will be used to vouch for the
-- impersonated context
--
GRANT AUTHENTICATE TO signing_cert
go
-- GRANT SELECT on the table to the impersonated context
--
GRANT SELECT ON dbo.data to crossdb_user
go
-- Test the new signed SP
--
use db_Source
go
CREATE APPLICATION ROLE approle_demo WITH PASSWORD = '@.ppr0l3 d3m00'
go
GRANT EXECUTE ON sp_demo to approle_demo
go
EXEC sp_setapprole 'approle_demo', '@.ppr0l3 d3m00'
go
-- Should fail
-- Msg 916, Level 14, State 1, Line 1
-- The server principal "<<login_name>>" is not able to access the database "db_Target" under the current security context.
--
SELECT * FROM db_Target.dbo.data
go
-- Should succeed
EXEC sp_demo
go
Please let us know if you have any questions.
Thanks,
-Raul Garcia
SDE/T
SQL Server Engine
|||
Thank you so much and forgive me for my late but was on holidays.
Your solution works fine, in fact (I am sure you have no doubts about it).
A more question, please forgive me if it is obvious:
how, from inside the sp_demo, can I get the name of the server principal (domain\user if Windows authentication) which set the application role ? I mean the caller of the setapprole.
Thank you very much.
Vania
Saturday, February 25, 2012
Application Login SQL Error
I created aASP.net 2.0 application usingC# on VS2005
The application access several database on a remoteSQL Server 2005
I recently added Login functionalties to the application, this created a MDF in the app_data folder.
Everything works fine on my local desk top...
I can access my remote SQL Server 2005
and the local MDF file works fine, I can create account, login and all that fun stuff
So I Published the site to my target server:
Which is the same server running the SQL Server 2005
The parts of the application that does not require login works fine, I can access the SQL server 2005 with ease..see data, update, everything
However when ever I try to login or create an account from the application(MDF file) I get this:
An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote connections.
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I can only assume that the problem is with the MDF file.
Can anyone point me in the right direction?
Thank you
Andre
This is often fixed by ensuring the Initial Catalog entry is in the connectionstring.
.....Initial Catalog=yourFileWithoutTheExt....
I just reread the error...actually, I think it's because you are trying to administer the DB from your PC, and it's not setup that way.
|||Thank you for responding,
On my target server I do not have SQL Express but SQL server 2005 and the remote setting for that is correct.
I changed my application from using the local SQL Express MDF file to use the SQL server 2005 for membership and roles by running aspnet_sql.exe to set up the database.
And all is working.
Thanks again
Andre
application login permissions...
if I created a sql standard as application login. should i assign
permissions of objects to that accout or should i create a role, assign
permissions of objects to the role, then add that application login account
to the role?
what are some of the common or best practices? can anyone give me some
suggestions? thank you.
steveHi,
I suggest you to create a role and assign permissions to that role.
Say if it is a Finance application, Create a new user role called Finance
and aiisn all permissions to that role. After this you can assign this role
to the application user. If there a new application user comes in later, you
can just assign that role to that user.
(Before creating the role, Just have a look into db_datareader and
db_datawriter role- this may help you out)
Thanks
Hari
MCDBA
"== Steve Pdx==" <lins@.nospam.portptld.com> wrote in message
news:#yfq2fuNEHA.1160@.TK2MSFTNGP09.phx.gbl...
> background sql2kt on nt5
> if I created a sql standard as application login. should i assign
> permissions of objects to that accout or should i create a role, assign
> permissions of objects to the role, then add that application login
account
> to the role?
> what are some of the common or best practices? can anyone give me some
> suggestions? thank you.
> steve
>
application login permissions...
if I created a sql standard as application login. should i assign
permissions of objects to that accout or should i create a role, assign
permissions of objects to the role, then add that application login account
to the role?
what are some of the common or best practices? can anyone give me some
suggestions? thank you.
steve
Hi,
I suggest you to create a role and assign permissions to that role.
Say if it is a Finance application, Create a new user role called Finance
and aiisn all permissions to that role. After this you can assign this role
to the application user. If there a new application user comes in later, you
can just assign that role to that user.
(Before creating the role, Just have a look into db_datareader and
db_datawriter role- this may help you out)
Thanks
Hari
MCDBA
"== Steve Pdx==" <lins@.nospam.portptld.com> wrote in message
news:#yfq2fuNEHA.1160@.TK2MSFTNGP09.phx.gbl...
> background sql2kt on nt5
> if I created a sql standard as application login. should i assign
> permissions of objects to that accout or should i create a role, assign
> permissions of objects to the role, then add that application login
account
> to the role?
> what are some of the common or best practices? can anyone give me some
> suggestions? thank you.
> steve
>
application login permissions...
if I created a sql standard as application login. should i assign
permissions of objects to that accout or should i create a role, assign
permissions of objects to the role, then add that application login account
to the role?
what are some of the common or best practices? can anyone give me some
suggestions? thank you.
steveHi,
I suggest you to create a role and assign permissions to that role.
Say if it is a Finance application, Create a new user role called Finance
and aiisn all permissions to that role. After this you can assign this role
to the application user. If there a new application user comes in later, you
can just assign that role to that user.
(Before creating the role, Just have a look into db_datareader and
db_datawriter role- this may help you out)
Thanks
Hari
MCDBA
"== Steve Pdx==" <lins@.nospam.portptld.com> wrote in message
news:#yfq2fuNEHA.1160@.TK2MSFTNGP09.phx.gbl...
> background sql2kt on nt5
> if I created a sql standard as application login. should i assign
> permissions of objects to that accout or should i create a role, assign
> permissions of objects to the role, then add that application login
account
> to the role?
> what are some of the common or best practices? can anyone give me some
> suggestions? thank you.
> steve
>
Friday, February 24, 2012
Appending to a record
I have created a Table that contains a WorksheetID field and a SalesNotes field. I can successfully populate that table but I am uncertain as to how I can append to the SalesNotes record.
I want to keep the orginal notes but populate addtional notes.
Would I do this by using the UPDATE call?
Many Thanks
T
Hi,you explanation is a bit unclear, but if you want to fill the table with additional data which can′t be filled during the initial load, you can sure use an update statement to modify the exisiting records.
HTH, Jens Suessmeyer.http://www.sqlserver2005.de
Appending to a record
I have created a Table that contains a WorksheetID field and a SalesNotes field. I can successfully populate that table but I am uncertain as to how I can append to the SalesNotes record.
I want to keep the orginal notes but populate addtional notes.
Would I do this by using the UPDATE call?
Many Thanks
T
Hi,you explanation is a bit unclear, but if you want to fill the table with additional data which can′t be filled during the initial load, you can sure use an update statement to modify the exisiting records.
HTH, Jens Suessmeyer.http://www.sqlserver2005.de
Appending Records to the Existing MS SQL EXPRESS SERVER Table.
Dear All,
I am Using MS SQL EXPRESS SERVER .I have installed all tools available to Express Edition site.
Now I have created my database on this .I have imported a table from my MS ACCESS database (Using ODBC Datasource).This table contains 10,000 records ,
Now I want to append 1 more access Table(5500 records) to the existing table having same fields.
How to do this.Can any body tell me?
Thanks and Regards
mukesh
Hi mukesh,
You can append the imported records into the existing table using SQL Server import & Export Wizard.
1.Select Your database from SQL Server Management Studio
2.Right Click on Database and go to the Task->Import Data menu Item
3. SQL Server Import & Export Wizard will be open., choose ur data source. as MicrosoftAccess, and select the MDB file
4.Press Next to Move onChoose a Destination Page, and select your Database Name from dropdown
5.Press Next to Move onSpecity Table Copy or QueryPage, and selectcopy data from one or more tables or viewradio button.
6. Press Next to Move onSelect Source Table and View , Select your Source Table , and Destination Table and then pressEdit button,Column Mappings dialog box will be open, chooseAppend rows to the destination tabelradion button option ( it will append the new records with existing records, in your case ur new 5500 records will be apended with existing 10,000 records )
7Press Next, and then Press Finish.Import Process will be started.
Thanks
Best Regards,
Muhammad AKhtar Shiekh
SQL Server Import & Export Wizard
|||Hi mukesh,
The way you imported the first table just load the second table but with a different name i.e Table2 to the same database and then you can use the query
Lets Table_1 is having 10000
Table_2 is having 5500
----------------
Insert into Table_1
Select * from Table_2
----------------
the simplest way to do the stuff...
Satya
Thanks Mr.Akhhttar
But sir in management studio I can't find "Import and Export option" there r these option,"detach","shrink","backup","restore"& generate scripts.
thanks and regards
mukesh
|||Thanks a lot,Mr.Satya
Sunday, February 19, 2012
Append Views
My Problem is
I have 2 views --> 2 Databases (2 Products) but there are same fields (Same structure)
and I have to created the report by Crystal Reports to compare the Quatity of all product in my Company
So how Can I combine them (2 views with the same recoed but not the same data)
thanks for helping me
Kate
You can try Linked Servers if your databases are on different servers or on different instances.
If they are on the same instance then you can use
select * from DatabaseName.dbo.TableName
OR
select * from DatabaseName..TableName
Eralper
Append Unicode string source to non-Unicode string destination
In SQL 2000 DTS, I was able to append data from an ODBC source to a SQL 2000 destination table. The destination table was created by copying an attached source table in Access to a new table, then upsizing it to SQL. The character fields come over as varchar, and that seemed to be fine with the DTS job.
Now using the same source table and the same SQL destination, only in SQL 2005 with Integration Services instead of DTS, I get an error because the connection manager interprets the source text fields as Unicode and the destination fields are varchar.
I could script the table and change the text fields in the destination table to nvarchar, but this could have adverse affect on the application that uses the destination table. Is there a way to make the connection manager see the source text fields as varchar, or have the integration package allow the append even though the destination is varchar and the source is nvarchar?
Use the Data Conversion component to change the values from DT_WSTR to DT_STR.
-Jamie
|||Thanks for the quick response. I was able to finish the SSIS package successfully.Thursday, February 16, 2012
Append new records from ODBC source
I have created a data warehouse that pulls information from an ODBC source into a SQL database. The schema in the destination matches the source, and the packages clear the destination tables, then append all the records from the source. This is simpler than updating, appending new, and deleting on each table to get them in sync since there is no modify timestamp in the source.
There are cases where I just want to append records from the source table that do not already exist in the destination table, without clearing the destination table first.
How can this be done with a SSIS job? Also, how can the job be run from a Windows Forms application?
Steve Jensen wrote:
There are cases where I just want to append records from the source table that do not already exist in the destination table, without clearing the destination table first.
Steve,
Have you considered to use a Lookup task in your data flow to check if the row already exists in the destination table and then use the error output (no matches) for inserting only non existing rows? Notice that the error output of the lookup task needs to be set as 'redirect rows' in order to get this behavior
|||Sounds good. Could you give me some detailed instructions for doing this?
Thanks,
Steve
|||Steve here is a detailed description:
http://blogs.msdn.com/ashvinis/archive/2005/08/04/447859.aspx
I Hope this can help you
Rafael Salas
|||Sorry, but I'm still at the 'first, you drag a data flow task onto the design surface ...' stage. I understand the concept but need a more step-by-step on how to do it.
Thanks,
Steve
Append new records from ODBC source
I have created a data warehouse that pulls information from an ODBC source into a SQL database. The schema in the destination matches the source, and the packages clear the destination tables, then append all the records from the source. This is simpler than updating, appending new, and deleting on each table to get them in sync since there is no modify timestamp in the source.
There are cases where I just want to append records from the source table that do not already exist in the destination table, without clearing the destination table first.
How can this be done with a SSIS job? Also, how can the job be run from a Windows Forms application?
Steve Jensen wrote:
There are cases where I just want to append records from the source table that do not already exist in the destination table, without clearing the destination table first.
Steve,
Have you considered to use a Lookup task in your data flow to check if the row already exists in the destination table and then use the error output (no matches) for inserting only non existing rows? Notice that the error output of the lookup task needs to be set as 'redirect rows' in order to get this behavior
|||
Sounds good. Could you give me some detailed instructions for doing this?
Thanks,
Steve
|||Steve here is a detailed description:
http://blogs.msdn.com/ashvinis/archive/2005/08/04/447859.aspx
I Hope this can help you
Rafael Salas
|||
Sorry, but I'm still at the 'first, you drag a data flow task onto the design surface ...' stage. I understand the concept but need a more step-by-step on how to do it.
Thanks,
Steve
Sunday, February 12, 2012
API for creating user or group
If you are using Forms auth then somebody has written a custom security extension that manages users and groups for you. (Perhaps you are using the sample?) In that case you can see if the security extension provides an API for adding users. If you are using the sample security extension, it does not provide a mechanism (outside of the logon page), you would have to add directly to the table it uses.
You are correct that RS has a table of users and policies, but it does not technically control this list. It always defers to the security extension. When a user comes in RS ask the security extension for the user name and then stores it so that it can keep track of owners. It also stores information on policies, but only to pass back to the security extension to allow the security extension to evaluate if a user has permission to perform the current operation.
|||I wrote the Forms Auth security extension and everything is working fine. I am just confused as to when RS create users and assign roles to them. For example, I want to initially create 5 users and give them permissions to certain folders. Those users are already created in the my own database but not in RS database. So if I use the API to set permissions for them, does RS automatically create the users in its own database? I am also curious as to what actually happens when a new user/group is created via Report Manager. Since Report Manager is built using the same exposed ReportServices2005 SOAP API, there must be a way to create users.|||RS only adds the users to it's database when it needs to reference the user. If a user creates an item in the catalog or subscribes to a report, the user will be added to our database.
As you said, Report Manager uses the Soap API so it doesn't create any users, it only makes soap calls which may result in a new user row in the RS database.
Is there a reason you feel that the RS database needs to have the user table populated? As long as your security extension knows the users, what RS stores shouldn't be an issue. Perhaps if you explain the issue you are facing we could address that.
|||I want to use Reporting Services to manage reports with several clients. When a new client is added, I will create a folder under the Home folder and create user accounts for their administrators. Then I will assign roles for each user to the folder. So I guess that as soon as I assign roles, that user will be created in the RS database.|||Yep, that is correct.|||Has anyone tried using the ASP.NET 2.0 Application Services (Membership and Role Management) together with custom extension to authenticate users?
I'm in the process of trying to configure this for a client. We are trying to use as much "out of the box" stuff as possible. Any samples would be usefull.