Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 UPDATE/REPLACE statements!

Author  Topic 

murtzzz
Starting Member

14 Posts

Posted - 2007-04-16 : 04:51:45
Hi!

Im really stuck on something.

I am currently working on making a Data Dictionary for work.. and Im trying to document all the tables and their attributes from the database. To do this.. I created SQL Scripts.. and fetched results from the script n placed them in a table.

Im getting something like this...

CREATE TABLE [dbo].[7dfu_carl1] (
[Discharged on] [datetime] NOT NULL ,
[ePEX number] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Patient] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

etc...

Basically.. im creating Update statements to single out the table names.. and its attributes.. and place them in diffent columns.

But there is one problem. As you can see some of the attributes have a Space in the middle.. and I need to replace the space with an underscore! eg [discharged_on].

Please help! I want to know how to replace the space between 2 square brackets!


Thanks!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-16 : 05:03:53
1) Use QUOTENAME function when retreiving the table/column names
2) Use REPLACE function and substitute space with underscore.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

murtzzz
Starting Member

14 Posts

Posted - 2007-04-17 : 04:33:06
Ok thanks...

Ive managed to sort the problem out.. however.. my data is all over the place.. Ive put an example below...



COL001 COL002 COL003 COL004

[Patient] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS
[Care_Coordinator_Team] Coordinator Team] [nvarchar] (30)
[team_id] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS

Basically.. The Care Coordinator Team was displayed in 3 different columns as [Care Coordinator Team].. I manage to join them all together an display it in the first column (I didnt have that problem with the other 2). However.. I still need to replace the data thats left in the 2nd and 3rd column with the relevant data.. So I want to move the NVarchar and (50) to their relevent columns (2 and 3 respectively)

Please help!
Go to Top of Page
   

- Advertisement -