Showing posts with label t-sql. Show all posts
Showing posts with label t-sql. Show all posts

Monday, March 26, 2012

replace T-SQL fonction

I would like to know how to use a replace fonction on a table
Like, currently, the syntax for replace is

SELECT REPLACE('abcdefghicde','cde','xxx')

but I would like to do something more like

SELECT REPLACE ((SELECT * FROM TABLE1) , 'cde', 'xxx')

Thanks to reply!I've found my problem ... which was in fact simple

it's:

select replace (FieldName , 'abc' , 'xxx') from MyTable...

the problem was that my FieldName was a Text field... which doesn't work... you need a varchar or nvarchar there...
so:

select replace (CAST(FieldName AS varchar(8000)), 'abc', 'xxx') from myTable

Thanks anyway!|||You should consider changing your fieldtype to VARCHAR if TEXT is not required. It will make coding easier and improve efficiency.

blindmansql

Wednesday, March 7, 2012

Repair SQL database that has been marked suspect

I woke up this morning to find my company's SQL database inaccessible and marked suspect.

I have used various t-sql commands to bring it into Emergency mode.

Now it is labelled Loading\Offline\Read-Only\Emergency Mode.

I'm using SQL Server 2000

I do not have a backup and I need to get the database up and running as soon as yesterday.

Help

first of all what version of SQL Server are u using?

Second ..There can be many reason for database being suspect.Please see in to the SQL Server error log and send if you see something unusual/error .It is very importent to look in to error log before anything can be done

run this on master

select status from sysdatabases and send it.

Thanks

|||

Recommended actions for corrupt or suspect databases

http://www.karaszi.com/SQLServer/info_corrupt_suspect_db.asp

AMB

|||

it is very tough to get a suspect db back. try this link http://www.myitforum.com/articles/18/view.asp?id=7381

Madhu