Click here to Skip to main content
15,895,011 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL string functions Pin
Mark J. Miller2-Apr-08 10:16
Mark J. Miller2-Apr-08 10:16 
GeneralRe: SQL string functions Pin
Yevgeny Efter2-Apr-08 18:52
Yevgeny Efter2-Apr-08 18:52 
GeneralRe: SQL string functions Pin
Mark J. Miller3-Apr-08 3:28
Mark J. Miller3-Apr-08 3:28 
GeneralRe: SQL string functions Pin
Yevgeny Efter3-Apr-08 8:01
Yevgeny Efter3-Apr-08 8:01 
GeneralWeird problem with some DB objects (SPs and Views) Pin
AlexeiXX32-Apr-08 7:10
AlexeiXX32-Apr-08 7:10 
GeneralRe: Weird problem with some DB objects (SPs and Views) Pin
Mark J. Miller2-Apr-08 9:25
Mark J. Miller2-Apr-08 9:25 
GeneralRe: Weird problem with some DB objects (SPs and Views) Pin
AlexeiXX32-Apr-08 9:49
AlexeiXX32-Apr-08 9:49 
GeneralRe: Weird problem with some DB objects (SPs and Views) Pin
Mark J. Miller2-Apr-08 10:14
Mark J. Miller2-Apr-08 10:14 
Renaming objects will always cause problems. If you need to find dependencies here are a couple scripts to allow you to search the source of views and stored procs. Just enter the name of the object you're looking for and you'll get a list of objects which contain your search phrase.

Search stored procedure:
DECLARE @find VARCHAR(1000)SET @find = 'enter your search phrase here'<br />
<br />
SELECT sp.name,<br />
ISNULL(smsp.definition, ssmsp.definition) AS [Definition]<br />
FROM sys.all_objects AS sp<br />
LEFT OUTER JOIN sys.sql_modules AS smsp ON smsp.object_id = sp.object_id<br />
LEFT OUTER JOIN sys.system_sql_modules AS ssmsp ON ssmsp.object_id = sp.object_id<br />
WHERE(sp.type = N'P' OR sp.type = N'RF' OR sp.type='PC')<br />
AND ISNULL(smsp.definition, ssmsp.definition) LIKE '%' + @find + '%'


Search view:
<br />
DECLARE @search VARCHAR(1000)SET @search = 'enter your search phrase here'<br />
<br />
SELECT c.[Text]<br />
FROM dbo.sysobjects AS vINNER JOIN dbo.syscomments c ON c.id = v.id<br />
	AND CASE WHEN c.Number > 1 THEN c.Number			ELSE 0 END = 0<br />
WHERE v.type = 'V' AND c.[Text] LIKE '%' + @search + '%'<br />



As far as dropping and recreating objects as long as your script creates tables before your other objects. What I always do when writing my scripts is follow the IF EXISTS DROP then CREATE pattern. That way when I have a large script which creates a large number of objects if I get errors due to dependencies the first time I run it then I just run it again. The first time creates all the objects, the second time will create any that failed on the first attempt.

If you don't like this, then when you generate your scripts run them on a test database. Create 2 script files - one with DROP statements and one with CREATE statements. Run your CREATE script and look for dependency errors. If you get any, run your DROP script then rearrange your CREATE statements to fix the dependency errors and run the CREATE script again. Rinse, wash, repeat.


GeneralRe: Weird problem with some DB objects (SPs and Views) Pin
AlexeiXX32-Apr-08 10:02
AlexeiXX32-Apr-08 10:02 
Questionhow to encrypt and decrypt stored procedure in sql server 2000 Pin
M.Ramesh2-Apr-08 2:11
M.Ramesh2-Apr-08 2:11 
AnswerRe: how to encrypt and decrypt stored procedure in sql server 2000 Pin
Mark J. Miller2-Apr-08 9:27
Mark J. Miller2-Apr-08 9:27 
GeneralRe: how to encrypt and decrypt stored procedure in sql server 2000 Pin
M.Ramesh2-Apr-08 19:39
M.Ramesh2-Apr-08 19:39 
GeneralInsert or Export data to SQL Server 2000 (Arabic Language) Pin
obarahmeh1-Apr-08 23:32
obarahmeh1-Apr-08 23:32 
GeneralRe: Insert or Export data to SQL Server 2000 (Arabic Language) Pin
Mark J. Miller2-Apr-08 9:30
Mark J. Miller2-Apr-08 9:30 
GeneralWork with query results inside a stored procedure Pin
Yevgeny Efter1-Apr-08 22:40
Yevgeny Efter1-Apr-08 22:40 
GeneralRe: Work with query results inside a stored procedure Pin
Rob Philpott1-Apr-08 22:54
Rob Philpott1-Apr-08 22:54 
GeneralRe: Work with query results inside a stored procedure Pin
Ali Rashid1-Apr-08 22:55
Ali Rashid1-Apr-08 22:55 
GeneralRe: Work with query results inside a stored procedure Pin
Yevgeny Efter1-Apr-08 23:02
Yevgeny Efter1-Apr-08 23:02 
GeneralRe: Work with query results inside a stored procedure Pin
Yevgeny Efter1-Apr-08 23:59
Yevgeny Efter1-Apr-08 23:59 
GeneralGenerating REPORTS DYNAMICALLY in Sql Server Reporting Services (SSRS 2005) Pin
Aswanth1-Apr-08 21:40
Aswanth1-Apr-08 21:40 
Generalconverting char to datatime Pin
uglyeyes1-Apr-08 21:34
uglyeyes1-Apr-08 21:34 
GeneralRe: converting char to datatime Pin
Ali Rashid1-Apr-08 22:24
Ali Rashid1-Apr-08 22:24 
QuestionHow to get max value from each row of the table Pin
Sallu17491-Apr-08 21:09
Sallu17491-Apr-08 21:09 
AnswerRe: How to get max value from each row of the table Pin
Rob Philpott1-Apr-08 22:58
Rob Philpott1-Apr-08 22:58 
GeneralSQL Script generator Pin
AlexeiXX31-Apr-08 20:24
AlexeiXX31-Apr-08 20:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.