Automatic Rename In FROM Clause Of Dependant Objects ?

Jul 23, 2005

I have a problem.
I should rename some tables which are referenced in numerous stored
procedures.
Is there any way to automatically replace old table name with new one in all
dependant stored procedures,
instead of manual replacement in every stored procedure ehich would be
time-consuming?

Thank you in advance.

View 4 Replies


ADVERTISEMENT

Best Way/product To Handle Db Rename In Sp Objects

Feb 1, 2007

My developers have an application using 3 databases called
mardemo,mardemowh,mararchive. However when the solution is deployed to the user the db's name will be changed per client. Since several sp.'s have joins and other processes that use the dbname, they have to be changed for each client. Currently it is a manual update. Is there a better solution anyone knows up that will not affect performance?

View 3 Replies View Related

How Can I Automatic Create All That Objects In Assembly In Simple Way ??

Jan 12, 2006

Hi
 
I use SQL code snippet to attach the CLR assembly (dll) to the SQL Server Express
 
CREATE ASSEMBLY [DatabaseAndImages]
AUTHORIZATION [dbo]
FROM 'C:CLR_File.dll'
WITH PERMISSION_SET = SAFE
 
That file content CRL Codes for 10 Stored Procedures & 3 UDT & 5 Functions & 6 Triggers
As you can see it's content large amount of DB objects !!
 
My Question is ..
Is there any simple way can I use it to extract or automatic create all that Objects in the Database without use separate SQL Statement for each one ??
 
By Example , I will use this SQL statement to create the sp_AddImage that already located inside the CLR dll file
 
CREATE PROCEDURE [dbo].[sp_AddImage]
       @ImageID [uniqueidentifier],
       @ImageFileName [nvarchar](max),
       @Image [varbinary](max)
WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [DatabaseAndImages].[StoredProcedures].[sp_AddImage]
 
 
But as you know .. I have many objects .. and I am in development phase and I will do change to that object many time and also may I will add much more €¦
 
I thing it's not good to write SQL Statement for each object and do changes every time when I change the object definition
 
Is there any one line of SQL statement can I use it to automatically create and extract all the objects inside the assembly ??
Or is there any way to do that Issue by simple operation ??
 
 
And thanks with my best regarding
Fraas

View 3 Replies View Related

Generate Script For All Databases(including All Objects Inside) In My Server Automatic

Mar 15, 2000

Hello,


This request is for sql7 on nt4.

I am searching for a sp that can generate the entire objects on all my databass in the server. Something like the 'Generate sql scripts' for sql7 but i need it to be capable to run as a scheduled job and automaticly enters in all my databases in the server.

I need to take sql scripts for all my development databases every night. I have something like 80 databases in development on the server.

Thanks

View 1 Replies View Related

Dependant Assemblies In CLR

Oct 12, 2006

This is related to one of my previous posts.

I am running a CLR stored proc that goes to an EDS (Novell) server with LDAP and returns records into a SQL table.

I am using the Novell ldap library.

I want to do this with SSL so my code referneces the Mono security library as well.

However when I make the call to the stored proc to run in SSL, I get an object not found error. I do not think that the the Novell assembly can "find" the Mono assembly.

Two points:
1/ I can do the SSL if I run it as an asp.net page (so I know the SSL works)
2/ The proc runs and pulls all the records in non-SSL (so I know the proc works)

Any ideas?

Thanks,

BIG

View 22 Replies View Related

Dependant Stored Procedures

Dec 4, 2000

I posted a similar question in the SQL7 forum but am not getting any replys.

"I need to move 65 tables onto their own filegroup. Is there anyway to do this without scripting the tables first and BCP etc? My concern is the dependant stored procedures, I don't want to have to script these also as there are hundreds of them."

If I wanted to drop and recreate some tables, how would I do so without upsetting the dependant stores procedures on these tables?
If I inserted the names into a table and wrote a cursor to pull out the dependant id's from the sysdepends table, then put them back after the drop and recreate (matching the old dependants with the new object ids) what kind of trouble am getting myself into? Thanks Patrick

View 2 Replies View Related

Dependant IDENTITY Columns

May 12, 2004

Anyone know if MS-SQL Server supports IDENTITY columns that are incremented for each new value of the column it depends on.

For exameple:
Let's say I have a client table with a ClientID column as it's PRIMARY KEY.
This column can be an auto-incrementing IDENTITY column.

Then I have an orders table. The PRIMARY KEY for the orders table is composed of (ClientID, OrderID). I would like the OrderID to be an IDENTITY field that increments by an arbitrary value (1 in this case) for every new value of ClientID...therefore creating a unique PRIMARY KEY.

The contents of the table would look like this

ClientID OrderID
------- -------
1 0
1 1
2 0
1 2
2 1
2 2
1 3

and so on....

MySQL (and maybe other RDMS's...I haven't checked) seems to do this automatically when you set a column as AUTOINCREMENT and then define a composite PRIMARY KEY on two fields.
I know this can be done manually using triggers, but I was wondering if there was a better way...

Thanks in advance

View 14 Replies View Related

Populate Field Dependant Upon 2 Tables

Aug 9, 2006

Hi,I have a 2 tables called 1.tblRisk which consists of Ref(pk), subject, status, staff & Dept(fk)2.tblDept which has Ref(Pk) & DepartmentHow do i get it to populate Department, when tblRisk Ref's Dept matches the Ref in tblDept i am using SQL Server 2000best regards

View 1 Replies View Related

Getting Information Dependant Upon Primary && Foreign Key

Aug 11, 2006

Hi All,
It seems I have been requested to carry out a complex query and the best way I think I can do this is with the use of a stored procedure. The problem is that I am not quite sure whether my SP is stated correctly and also how I would go about stating the SP in my VB.net code!
 
I would be ever so grateful if somebody could look over my SP code and possibly recommend a way of stating my code. My ability is limited so I would appreciate it if examples could be used with possible relations to my problem.
 
The Problem?
 
Tables:
 
1.tblRisk: Ref(pk), subject, status(fk), staff(fk), Dept(fk)
 
2.tblDept: Ref(pk), Department
 
The SP should state that Department should appear as the end result of the query when the page is loaded. So when a row is selected in tblRisk, dependant upon what the Dept is in that table, it then populates the department in which it is associated with from tblDept. I have left the SP below.  
 
Many Thanks,
Kunal   
 
CREATE PROCEDURE dbo.ShowMe @yourInputValue INTAS  SELECT tblDept.Department    FROM tblDept    JOIN tblRisk      ON tblDept.Ref = tblRisk.Dept  WHERE tblDept.Ref = @yourInputValue RETURN 0GO

View 1 Replies View Related

Is This Outer Join Implementation Dependant?

Jan 9, 2007

Hi all,
Sorry if it looks a little cluttered!I have these two tables: CAMPAIGN(MEDIACODE varchar(10) UncheckedSPECIALOFFERCODE varchar(15) UncheckedLAYOUT varchar(10) UncheckedHEADERTEXT varchar(100) CheckedSORTORDER varchar(10) UncheckedSORTORDERCOLUMN varchar(50) UncheckedWIDTH varchar(50) Checked)andPROMORATEVIEW(MEDIACODE varchar(10) CheckedSPECIALOFFERCODE varchar(15) CheckedCAMPAIGNCODE varchar(15) CheckedNUMBEROFISSUES smallint CheckedRATE decimal(9, 0) CheckedDESPATCHMETHODCODE varchar(50) Checked)CAMPAIGN HAS ONLY ONE ROW:(CE DG8398 GRID ASC NUMBEROFISSUES NULL)ANDPROMORATEVIEWTOO MANY AND HERE A VERY SMALL RANGE OF RECORDSMEDIACODE SPECIALOFFERCODE CAMPAIGNCODE NUMBEROFISSUES RATE DESPATCHMETHODCODE(...CE CER1R02 CER1 12 429 WCE CER1R03 CER1 24 829 WCE CER1R03 CER1 12 429 WCE DG8398 DG8398 12 411 FCE DG8398 DG8398 12 405 1CE DG8399 DG8399 12 399 WCE DG8399 DG8399 12 735 1CE DG8399 DG8399 12 756 ACE DG8400 DG8400 12 756 ACE DG8400 DG8400 12 396 W...)Now the question:Why these two OUTER JOINS RETURN the same number of rows in My Sql2000 & 2005 express???1.SELECT DISTINCT P.MEDIACODE, P.SPECIALOFFERCODE,CD.MEDIACODEFROM CAMPAIGN AS CD RIGHT OUTER JOINPROMORATEVIEW AS P ON P.MEDIACODE = CD.MEDIACODE AND P.SPECIALOFFERCODE = CD.SPECIALOFFERCODE2.SELECT DISTINCT P.MEDIACODE, P.SPECIALOFFERCODE,CD.MEDIACODEFROM CAMPAIGN AS CD RIGHT OUTER JOINPROMORATEVIEW AS P ON P.MEDIACODE = CD.MEDIACODE AND P.SPECIALOFFERCODE = CD.SPECIALOFFERCODE AND CD.SORTORDER IS NULLIf you still with me here is what I am trying to do:to right outer join the campaign with promorateview and the if it's not overriden in campaign( there is no record for MEDIACODE, SPECIALOFFERCODE in campaign ) I will use that view to override the default values.I suspect that the last statement makes no "influence" on right outer join.Another work around for me now is that if I create a view that has these values and then filter it with VIEW.SORTORDER IS NULL it does the job but I am trying to get rid of this extra view.Thanks for your time, avarair

View 8 Replies View Related

Dependant Parameters In Report Subscription

Apr 17, 2008



Hello,
i am trying to subscribe to a report that has dependant parameters, for example Country->City and Year-> Month.
Those values are coming from a Analysis Services cube dimensions.
when i come to it in the subscription window, some of the parameters are populated and some are not.
I cannot detect a pattern.
Does anyone know what can be the problem?
thank you.

View 1 Replies View Related

Linked Server Query (dependant On Variable)

Nov 27, 2007

Hello,

I hope someone can help me on this one, as I am getting a bit frustrated with my research..

I have procA on ServerA.DatabaseA and it uses an input parameter to get a value that determines which server to ping.

If this parameter is @paramA = 1, then query into LinkedSrvX. If @paramB = 2, then query into LinkedSrvY... etc.

Is there an easier way to do this or a best practice? I really don't want to go into repeating my queries for every server. Here is a tsql mini version of what I am trying to enhance as my original queries are 1000 lines long and I need to get away from the repeated queries. I do have queries that ping within the server and to other linked servers as well without issues.

All linked servers referenced below have the same structure of tables. I also need to avoid situations incase the server may be down, this proc should not return errors.

My Partial Procedure


CREATE PROC procA

@paramA varchar(1) AS


IF (@paramA = '1')


BEGIN



SELECT ColA, ColB

FROM LinkedSrvX.Database0.Owner.Table0

END

IF (@paramA = '2')


BEGIN


SELECT ColA, ColB

FROM LinkedSrvY.Database0.Owner.Table0

END

IF (@paramA = '3')


BEGIN


SELECT ColA, ColB

FROM LinkedSrvZ.Database0.Owner.Table0

END

GO

All ideas / suggestions are welcomed.

Thanks!
-Ashvi

View 5 Replies View Related

Constructing A View Into Time Dependant Data

Oct 18, 2006

1. I have a table with data like this:

PersonID
DateTime
Temperature
Pressure



2. I want to build a view into this table so that it shows up as follows:

PersonID DateTime1 DateTime2 DateTime3 .....
1 Pressure1 Pressure2 Pressure3 ......
1 Temperature1 Temperature2 Tempearture3 .....
2 :
:

how would I do this?

View 5 Replies View Related

Putting Names Of Objects To Control-flow Loop Creating Objects

Dec 27, 2006

please help newbieI need to create a lot of objects the same type (let's say: schemas)I wish to use paramerized block in loop to do so.- how to put names of my objects to such control-flow?belss you for help

View 5 Replies View Related

SQL Server 2012 :: Select Data From XML - Objects Within Objects?

Nov 20, 2013

passing serialised objects to a stored procedure for the purpose of data inserts. I see this as being a way to handle multiple row inserts efficiently.

However, in my limited use of XML data I am not so sure how to link the data when I have a dependency on another "object" within the serialised XML.

Below is a code snippet showing what I have so far.

The first insert statement works fine - but how to retrieve the identifier created by the DB - I want to use an SQL statement that finds the record in the table based on the XML representation (of the PluginInfo), allowing me to insert the ConfigurationInfo with the correct reference to the PluginInfo

DECLARE @Config NVARCHAR(MAX)
DECLARE @Handle AS INT
DECLARE @TransactionCount AS INT
SELECT @Config = '
<ConfigurationDirectory >
<ConfigurationInfo groupKey="Notifications" sectionKey="App.Customization.PluginInfo"

[code]....

View 1 Replies View Related

Transact SQL :: How To Create UNION Clause With Two Queries That BOTH Have WHERE Clause

Nov 4, 2015

I have a quite big SQL query which would be nice to be used using UNION betweern two Select and Where clauses. I noticed that if both Select clauses have Where part between UNION other is ignored. How can I prevent this?

I found a article in StackOverflow saying that if UNION has e.g. two Selects with Where conditions other one will not work. [URL] ....

I have installed SQL Server 2014 and I tried to use tricks mentioned in StackOverflow's article but couldn't succeeded.

Any example how to write two Selects with own Where clauses and those Selects are joined with UNION?

View 13 Replies View Related

GROUP By Clause Or DISTINCT Clause

Jul 23, 2005

Hi, can anyone shed some light on this issue?SELECT Status from lupStatuswith a normal query it returns the correct recordcountSELECT Status from lupStatus GROUP BY Statusbut with a GROUP By clause or DISTINCT clause it return the recordcount= -1

View 3 Replies View Related

Filtering Results In The Where Clause Vs A Having Clause

Oct 25, 2007

I am working with a vendor on upgrading their application from SQL2K to SQL2K5 and am running into the following.

When on SQL Server 2000 the following statement ran without issue:

UPDATE dbo.Track_ID

SET dbo.Track_ID.Processed = 4 --Regular 1 leg call thats been completed

WHERE Processed = 0 AND LegNum = 1

AND TrackID IN

(


SELECT TrackID

FROM dbo.Track_ID

GROUP BY TrackID

HAVING MAX(LegNum) = 1 AND


TrackID + 'x1' IN


(


SELECT

dbo.Track_ID.TrackID + 'x' + CONVERT(NVARCHAR(2), COUNT(dbo.Track_ID.TrackID))

FROM dbo.Track_ID INNER JOIN dbo.transactions


ON dbo.Track_ID.SM_ID = dbo.transactions.sm_session_id

GROUP BY dbo.Track_ID.TrackID

)

)
Once moved to SQL Server 2005 the statement would not return and showed SOS_SCHEDULER_YIELD to be the waittype when executed. This machine is SP1 and needs to be upgraded to SP2, something that is not going to happen near time.

I changed the SQL to the following, SQL Server now runs it in under a second, but now the app is not functioning correctly. Are the above and the following semantically the same?


UPDATE dbo.Track_ID

SET dbo.Track_ID.Processed = 4 --Regular 1 leg call thats been completed

WHERE Processed = 0 AND LegNum = 1

AND TrackID IN
(



SELECT TrackID

FROM dbo.Track_ID

WHERE TrackID + 'x1' IN


(


SELECT dbo.Track_ID.TrackID + 'x' + CONVERT(NVARCHAR(2), COUNT(dbo.Track_ID.TrackID))

FROM dbo.Track_ID INNER JOIN dbo.transactions


ON dbo.Track_ID.SM_ID = dbo.transactions.sm_session_id

GROUP BY dbo.Track_ID.TrackID

)
GROUP BY TrackID

HAVING MAX(LegNum) = 1

)

View 3 Replies View Related

Expression Defined In SELECT Clause Overwrites Column Defined In FROM Clause

May 14, 2008

2 examples:

1) Rows ordered using textual id rather than numeric id


Code Snippet
select
cast(v.id as nvarchar(2)) id
from
(
select 1 id
union select 2 id
union select 11 id
) v
order by
v.id






Result set is ordered as: 1, 11, 2
I expect: 1,2,11


if renamed or removed alias for "cast(v.id as nvarchar(2))" expression then all works fine.

2) SQL server reject query below with next message

Server: Msg 169, Level 15, State 3, Line 16
A column has been specified more than once in the order by list. Columns in the order by list must be unique.




Code Snippet
select
cast(v.id as nvarchar(2)) id
from
(
select 1 id
union select 2 id
union select 11 id
) v
cross join (
select 1 id
union select 2 id
union select 11 id
) u
order by
v.id
,u.id




Again, if renamed or removed alias for "cast(v.id as nvarchar(2))" expression then all works fine.

It reproducible on

Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) May 3 2005 23:18:38 Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)


and


Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86) Feb 9 2007 22:47:07 Copyright (c) 1988-2005 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

In both cases database collation is SQL_Latin1_General_CP1251_CS_AS

If I check quieries above on database with SQL_Latin1_General_CP1_CI_AS collation then it works fine again.

Could someone clarify - is it bug or expected behaviour?

View 12 Replies View Related

Rename

Jun 6, 2008

i am trying to set up a way of renaming a table in a sp.

ive been using

exec sp_rename 'old table', 'new table'

however if i try and specify to database and owner i end up with a weired db.owm.db.own.table name in the outcome. ive tried putting using it without specifying a db name in a sp and then sched job to exec the sp but it doesnt rename, probably because it doesn know which db to look for the ld table name in. however the sched job doesnt fail?

any ideas?

View 2 Replies View Related

Rename SP

Nov 5, 2007

Hello All,

Does anyone know how to rename SP using Transact SQL ?

Thanks in advance

--kneel

View 10 Replies View Related

ERROR [42000] [Lotus][ODBC Lotus Notes]Table Reference Has To Be A Table Name Or An Outer Join Escape Clause In A FROM Clause

May 27, 2008

I am using web developer 2008, while connecting to I wanted to fetch data from Lotus notes database file, for this i used notesql connector, while connectiong to notes database i am fetting error


ERROR [42000] [Lotus][ODBC Lotus Notes]Table reference has to be a table name or an outer join escape clause in a FROM clause


I have already checked that database & table name are correct, please help me out
How i can fetch the lotus notes data in my asp.net pages.

View 1 Replies View Related

ERROR [42000] [Lotus][ODBC Lotus Notes]Table Reference Has To Be A Table Name Or An Outer Join Escape Clause In A FROM Clause

May 27, 2008

I am using web developer 2008, while connecting to I wanted to fetch data from Lotus notes database file, for this i used notesql connector, while connectiong to notes database i am fetting error


ERROR [42000] [Lotus][ODBC Lotus Notes]Table reference has to be a table name or an outer join escape clause in a FROM clause


I have already checked that database & table name are correct, please help me out
How i can fetch the lotus notes data in my asp.net pages.

View 1 Replies View Related

Rename Aspnetdb ?

Jun 4, 2007

 Hello,I have a shared hosting plan which already has aspnetdb.mdf on the server so of course I cannot use that db name for my site...I have renamed the db and now I get an error Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion My question is, how can I make this thing work?  All help is greatly appreciated! 

View 12 Replies View Related

SQL Server Rename

Aug 12, 2007

Can anybody please tell me how to rename an sql server express.
I have an SQL server instance named 'PC075/Sqlexpress'. I have to change it to 'PC075'.
Thanks,

View 4 Replies View Related

How To Rename A DTS Package

Dec 4, 2001

Hello every one

Does someone know how a DTS package can be renamed ?

TIA

View 1 Replies View Related

Rename Sql Server

Jul 16, 2002

if my computer name is x and sql server was installed and therefore took on the default name of x, can I change the sql server name to y at a later date while the computer name remains as x? If so how do I do it?

The sp_addserver is internal recognition. But I want to connect to sql server using the new name y.
I am assuming setup needs to be run only if computer name also changes to y and this is not the case.

Any help is appreciated.

View 4 Replies View Related

Rename Object

Apr 19, 2001

Is there a way to rename a object across server using the sp_rename sp. I have a job running across server and I one of the steps requires me to rename a object on a different server.

View 1 Replies View Related

Rename DB Files

Oct 22, 2001

In EM, when you right click a database and go to properties you can see on the general tab the file name,the location,the space allocated in MB and the file group.
Is it possible to change the file name and how you achieve it?
Where are these names stored?
I really appeciate any suggestions.
Thank you very much!
Franco

View 2 Replies View Related

Rename SQL Server

Jul 14, 2000

To all,

I would like to rename my SQL server. Someone suggested SQLServer and we went with it, but after some discussions with other developers we thought that this name would be a hackers delight. So now I need to rename it to something that wouldn't put a "bulls eye" on its back. Any suggestions? :-)

This machine is not in production just yet, so if I had to reinstall SQL it wouldnt' be that bad of an option.

Thnx.

Michael Fanara

View 2 Replies View Related

Rename Server With Sql 7

Nov 20, 2000

Hello, I want to rename a server NT4 on whom is bases sql server sql 7 sp 2, who is the precautions to set and can you indicate me the procedure. Thank you in advance.
pascal

View 2 Replies View Related

Rename DTS Package

Aug 17, 2000

How can we rename a dts package programmatically? (Without using EM save as option)

View 1 Replies View Related

Rename Sql Server

Mar 2, 2001

How can I change the name of an SQLServer to have a name different than
the machine it is runnning on?

View 2 Replies View Related







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