The Target Is Not In The Current Database

May 18, 2007

Can someone please help me with the following error?



I am trying to create a trigger that copies data from a table in one database to another. However I am getting the error 'Cannot create trigger on databasename.dbo.tablename as the target is not in the current database.



Below is the SQL I am using to create the trigger:

create trigger addtotable1

on databasename.dbo.tablename

for insert

as

insert into anotherdatabase.dbo.tablename

select databasename.dbo.tablename.userid, databasename.dbo.tablename.username, biadatabasename.dbo.tablename.issuperuser

from databasename.dbo.tablename, inserted

where databasename.dbo.tablename.userid = inserted.userid

and inserted.roleid = 3



Andrew Ling

View 8 Replies


ADVERTISEMENT

How Deploying A Local Database To Target Machine?

May 9, 2005

how deploying a local database to target machine?

View 1 Replies View Related

SQL Security :: View Definition Permission On Target Database

May 15, 2015

I am trying to do a schema compare and data compare via VS2012 and I am getting below error: The reverse engineering operation cannot continue because you do not have View Definition permission on the 'Target' database.

Whats interesting is I created a viewdefinition role and added the group(to which the user belongs) to the role. However I dont get the error if I make the group the dbowner. Is this a bug?

View 2 Replies View Related

What Will Happen In Target Database When Publishing Profile File Is Not Being Used

Sep 18, 2015

I'm exploring using VS2013, TFS 2013 and Release Management for DB projects.In VS 2013 the deployment configuration is stored in the publishing profile, which is not necessarily being used by deployment tools. (Release Management for example, while it's supporting the profiles, it does not require them) So, the question is how to control what will happen in the target database when the publishing profile file is not being used?

Is there any way to store the deployment configuration with project so it will be applied by default?For example, if I want to control the following settings: Block incremental deployment if data loss may occur...Drop objects in the target DB that are not in the DB project, e.t.c.

View 6 Replies View Related

VS 2013 - Schema Compare Is Not Applying Changes To Target Database Project

Aug 11, 2015

I have created Database projects in VS 2013 using SSDT. I have been mostly successful in creating and building the projects without any errors/warnings.

However for one of the databases in the project, when i do schema compare to apply the changes from a SQL Server Database to a Database Project in VS, code changes are not applied to the database project.

After i select the Update option in Schema compare window, I'm getting the following message

"Target update complete. Press Compere to refresh the comparison."

Even tough the message implies that target database is updated successfully, I do not see the objects i selected in schema compare being added to the target database project.

I see the following warning

"Target update: Could not update script for element 'dbo'"

I have 9 Database projects in the Solution and I'm able to apply changes to 8 of the database projects through schema compare successfully. I get the same warning after schema compare for all database projects.

I have same project level setting for all database projects in the solution. I'm using Visual Studio 2013 Premium Update 5 SQL Server Data Tools 12.0.41012.0

View 3 Replies View Related

Row Count Validation Between Source Flat File To Target Database Table

Aug 8, 2006

Hi all,



I am new in SSIS. Anyone know how to valify number of record that I load from csv file to SQL database table?



For example, the source file call product.csv and target table in database named DSS table name PRODUCT. I load data from flat file to table then I need verification if count between source and target not match send e-mail to me.



Thanks.

Grace

View 5 Replies View Related

The Database Name Component Of The Object Qualifier Must Be The Name Of The Current Database

Apr 7, 2006

Guys,1st of all.. sorry about my english ok? Im from Brazil...Im trying to get a RS connecting through 2 databases with the querybelow:SELECTscar..osbalcao.numeroos,ccell.dbo.atrib_os.osFROMccell.dbo.atrib_osJOIN scar.dbo.osbalcao on ccell.dbo.atrib_os.os =scar.dbo.osbalcao.numeroosWHERE scar.dbo.osbalcao.localprod = '257'AND scar.dbo.osbalcao.status in ('EM')On a SQL IDE i got a good RS, but, when i try to use that same query onDelphi + ZEOS, the SQL Server tells me that "The database namecomponent of the object qualifier must be the name of the currentdatabase".I really dont understand why. I can only tell that the error isreturned from SQL Server.Have anyone got the same trouble?[]'sTiago Gigli

View 1 Replies View Related

Accessing Tables Of A Different Database From The Current Database

Apr 15, 2008



Hi,

In a stored procedure is there a way of accessing a table presend in another database.

Please provide pointers on how i can do this.

Thanks,
Raj

View 4 Replies View Related

Acessing Tables Of Different Database From Current Database

Apr 15, 2008

Hi,

In a stored procedure is there a way of accessing a table present in another database.

Please provide pointers on how i can do this.

Thanks,
Raj

View 4 Replies View Related

Current Database

Oct 19, 1999

Hi,

Is there any command that gives the current database name.

Regards
Kishore

View 1 Replies View Related

How To Get Current Database Name?

Aug 4, 2006

How to get current database name using stored procedure?

View 2 Replies View Related

Current Database Name...

Mar 26, 2004

Hi,
I want to know a sql query that would show the current database name.
I have tried looking into the online books but couldn't find the right query.I hope u can do better.This is urgent.Thanxs. -- Vijay

View 2 Replies View Related

Current Database Name Needed...

Apr 10, 2002

Hi:

I need to know the current database name in executing a stored procedure,
which will trancatte the log of that database.
(in a dynamic multiple customerID oriented database environment,
ex. custID_101_db, custID_102_db, .....)

View 1 Replies View Related

Selecting Current Database

Apr 27, 2007

Hello,

When I open a query analyzer , of a particular database for example 'AB'

when writting a query how can I get the databasename that I am executing

i.e in the result I should get the DB name.

I was trying select name from master..sysdatabases . But it was returning all DB names.

Also while running a query , can I prompt for the DB name , so that that particular db name can be used to run that procedure or query.

Thanks in advance

View 2 Replies View Related

Check Current Database

Jun 18, 2007

I was wondering if it was possible to check what server database you are currently connected to, using T-SQL, when executing commands in Query Analyzer. Even though you choose the server and database when connection, sometimes by habit you may connect to the wrong server & DB, and execute an .SQL file. Is it possible to put a line of T-SQL at the beginning that performs this pseudo-code, as a safety feature:-- While in Query Analyzer with a certain .SQL file open:If current server <> 'TheCorrectServer' and current DB <> 'TheCorrectDB' then cancel this .SQL file execution.

View 3 Replies View Related

Can Alter (current) Database?

Apr 7, 2006

I have a *.sql script that creates database tables, and I need to modify the database to enable the service broker. In addition, the actual name of the database is not known in advance - it is set per instance of the application.

I know I need to do:

ALTER DATABASE dbname SET ENABLE_BROKER

But I must avoid including the name of the database in the script. I did wonder if this would work:

DECLARE @DB varchar(50)

SELECT @DB = DB_NAME()

ALTER DATABASE @DB SET ENABLE_BROKER

But I just get a syntax error. Presumably this also rules out setting the database name as a parameter to the script (SqlParameter stuff)

The only option I can think of is dynamically creating the statement, either in T-SQL or in the calling .NET environment.

Any thoughts?

Ruth

View 6 Replies View Related

I Want To Join One Table From The Source To The Other Table In The Target Diff Database

May 1, 2008




Hello I have a Source database and a Target database.

I want to join one table from the source to the other table in the target.

Please can some one write a sql query for this.

i gues its something like

select tablesource.col,tabledest.col
from database..tablesource,database..tabledestination

Ok One more question is where do I execute this Query in which database.. IF at all its possible to this.

View 4 Replies View Related

Database Query Won't Use Current Date

Mar 11, 2008

Hi, I've just started using SQL Server Express with VWDE 2005 and I have a database with one table called EVENTS which has a datetime column called DATE. I want to select records where the DATE value is in the next two months.First I tried selecting records where the DATE value is >= today. I used the query builder to produce... SELECT [Date], [Title] FROM [Events] WHERE [Date] >= GETDATE()but got the error "Undefined function 'GETDATE' in expression".Am I missing something obvious? 

View 5 Replies View Related

Other Way Of Setting Current Database In SQL Script

Nov 7, 2001

Hi,
I'm trying to create an SQL script that creates a new login account for each of our databases. The one remaining problem with the sql is it could not set the current database using a variable(e.g. USE @dbasename). I tried looking for another way of setting the current database but could not find one.

Is there any other way of setting the current database other than the USE command?

Any help/suggestion will be appreciated.

Thanks in advance,
Julius

View 1 Replies View Related

Quick Question: How Do I Get The Name Of The Current Database?

Jul 23, 2005

Is there an sp_zzzzzz function to return the name of the current database?I would like to use this name as a variable in a stored procedure in orderto create names for further databases (by appending a tag, such asMYDATABASE_BLOB001, ..._BLOB002 etc.Thanks.

View 4 Replies View Related

Select No. Of Rows From The Current Database

Jul 19, 2006

Hello,I want to select the names and number of rows of all tables in thecurrent database, whose name starts with 'sys'my query is:select o.[name], sum(i.[rows]) as numbersfrom sysobjects oinner join sysindexes ion (o.[id] = i.[id])where o.[name] like 'sys%'and i.indid=1group by o.[name]the result of the query is (depending of the database) :name numberssysaltfiles 14syscharsets 114syscolumns 4934syscomments 2035sysconfigures 38sysdatabases 7sysdepends 5524sysdevices 6sysfilegroups 1sysfulltextcatalogs 0sysfulltextnotify 0sysindexes 98syslanguages 33sysmessages 3795sysobjects 1285syspermissions 806sysproperties 0sysreferences 0sysservers 1systypes 26sysusers 14sysxlogins 3But when I count the number of rows of "sysobjects", I getnumbers=1298, which is different from the result displayed above andsame goes for "syscolumns".I also tried "dbcc updateusage [0]" to update the SQL Server but Ididnt help me.Can anyone please advice me on this behaviour?

View 2 Replies View Related

How To Determine Sp Caller Current Database?

Aug 23, 2007

When executing a stored procedure that is defined in another database, as:

USE db1;

EXEC db2.dbo.sproc;

Is there a way in the stored procedure "sproc" to determine that the caller made the call from db1?

View 1 Replies View Related

How Can I Get The Name Of The Current Database In Variable PROCEDURE

May 22, 2008

i need to know the name of the current database in variable
like "Northwind"
so i can use it inside PROCEDURE

tnx

View 5 Replies View Related

Get Rows Between Current Date And Current Time

Jun 8, 2008

I've this query
SELECT
t1.ID, t1.Date, t1.Time,
t1.VALUE
FROM RESULT WHERE t1.Date>=CONVERT(VARCHAR(10),DATEADD(d,-7,GETDATE()),101) AND
t1.Date<CONVERT(VARCHAR(10), GETDATE(), 101)

Let's say, current date is 8 AUG 2005 and current time is 2045
So, i will get
ID | Date (this is datetime) | Time (this is integer) | Value
--------------------------------------------------
204 | 8/1/2005| 2359 | 90
205 | 8/1/2005| 2250 | 99
206 | 8/1/2005| 1950 | 88
...
...
207 | 8/7/2005| 1845 | 77
208 | 8/7/2005| 2255 | 77
209 | 8/7/2005| 2140 | 77

Can someone can show me to filter data between
t1.Date>=CONVERT(VARCHAR(10),DATEADD(d,-7,GETDATE()),101) AND TIME>=CurrentTime
t1.Date<CONVERT(VARCHAR(10), GETDATE(), 101) AND TIME<=CurrentTime

If current date is 8 AUG 2005 and current time is 2045, so the result shown as follow

ID | Date (this is datetime) | Time (this is integer) | Value
--------------------------------------------------
204 | 8/1/2005| 2359 | 90
205 | 8/1/2005| 2250 | 99
...
...
207 | 8/7/2005| 1845 | 77

I only have this query,
SELECT
t1.ID, t1.Date, t1.Time,
t1.VALUE
FROM RESULT WHERE t1.Date>=CONVERT(VARCHAR(10),DATEADD(d,-7,GETDATE()),101) AND
t1.Date<CONVERT(VARCHAR(10), GETDATE(), 101)

lack of idea to put the TIME condition.

Plz help me..

View 14 Replies View Related

The Current User Is Not An Owner Of The Selected Database

May 29, 2007

I have recently installed SQL 2005 I use the SQL ecpress and management studio.   In the SQL server Management Studio, when I right click on the database and use the SQL Server Import and Export wizard, I can import databases from the web hosting I'm workign with to my mycomputer, but cannot export them.
 When I try to export database tables with the SQL Server Import and Export wizard
The error says: The current user is not an owner of the selected database. This might cause some operations with this database to fail.I use sa to log into the management studio aand creat teh database after I login.  How do I create a database so that the user and owner match and will allow me to export tables and data?

View 5 Replies View Related

How To Retrieve Current Userid To Update Database

Feb 12, 2008

 I am making a web site in which i need to update a database with certain values which include the current user who invoked the insert command so how to retrieve the current userID 

View 4 Replies View Related

How To Change Current Database In Sp (detail Inside)

May 30, 2000

Hi,
I want to write a sp with structure:
PROCEDURE TEST
@dbname1 varchar(25)
@dbname2 varchar(25)
AS
1. change current database to another, example for DB1 database
2. execute commands or block commands in DB1
3. change current database to another, example for DB2 database
4. execute commands or block commands in DB2
...
Can I do that? Who can help me? Thanks.
qhbaby@hotmail.com

View 1 Replies View Related

User Or Role Already Exists In The Current Database

Oct 9, 2000

Hi!
I've restored a backup from server A in server B. In server A I used to have a db_owner, called sitebase. After restoring the backup in server B, I created the user sitebase again and tried to grant him db_owner through Server Manager but I got the error: user or role already exists in the current database.
How can I avoid this situation and grant db_owner to him?
Thanks,
Fábio

View 1 Replies View Related

How To Find All Permissions In The Current Database For A Particular User

Oct 4, 2006

How to find All Permissions in the Current Database for a particularUser in SQL 2005 ?ThanksM A Srinivas

View 1 Replies View Related

The Current User Is Not An Owner Of The Selected Database

May 29, 2007

I have a SQL 2005 question for you. In the SQL server Management Studio. When I right click on the database and use the SQL Server Import and Export wizard, I can import databases but cannot export them.



The error says:

The current user is not an owner of the selected database. This might cause some operations with this database to fail.


I use sa to loginto the server Management Studio, does anyone know how to create a database where the user and owner are the smae so I can export?

View 5 Replies View Related

Please Help! How Can I Check The Current User Against A Specific Database?

Apr 29, 2008

In my application (infopath browser forms), First I get current user name thru System.Environment.UserName, after that, i want to check whether this user has access (read & write) permission to certain database, How do I do that?
One way I tried before is to get all the users and stored the names in an array for comparing in my program, but can not figure out the SQL command (to get the database users), if there it is, please kindly tell me.
Or if I can just pass the current user to check?
Thanks in advance.

View 5 Replies View Related

Passing In Current Database Name To DTS-based SQL Task?

Sep 28, 2006

Hi all--I am writing a DTS package looking to back up all databases in sequence. I am calling CDOSYS in a stored procedure from support.microsoft.com to send email upon failure. I have two types of tasks I am writing into the DTS package:

1. backup database <database> to disk = '<drive>:<path>.bak' with init

2. Upon failure, send the following message:

declare @srvname varchar(128),
@db_name varchar(128),
@msg nvarchar(4000)

select @srvname=srvname from master.dbo.sysservers
print @srvname
select @db_name=name from master.dbo.sysdatabases
print @db_name
set @msg='Hi--check your database backups. The ' + @db_name + ' database backup on ' + @srvname + ' has failed.

Thanks--SQL Server';

Upon success, go to the next database to back up, execute through these steps for the next database. Here's my problem: The @db_name variable captures the proper value for the current SQL Server, but I want to turn both @srvname and @db_name into global variables. I would like to pass in @db_name as the current database being backed up (and failing), and @srvname as the current SQL Server instance being backed up.

The above statement "select @db_name=name from master.dbo.sysdatabases" definitely does not capture the current database name value. Any suggestions as to how to pass this in, if not as a global variable?

Thanks in advance,

Jonathan

View 2 Replies View Related

Inserting The Current Date And Time Into SQL Server Database

Mar 30, 2007

I need an SQL string that inserts the current date into a database.
So far I have tried:
SQL = "INSERT INTO X (START_DATE) VALUES ('" & Date.Now & "')"
mycomm = New SqlCommand(sql, myconn)
mycomm.ExecuteNonQuery()
However, there is a problem with the SQL command. The problem is related to the date. Is there a way of programatically inserting the current date/time into the SQL database? Language used is VB.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved