Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Sunday, March 25, 2012

Delete a Substring

Good morning,
I need to delete the first ten characters from a field, I don't know how to write this query to allow me to do so.update table
set COLUMN = LTRIM(NAME, SUBSTR(COLUMN, 0, 10));|||UPDATE conitemdescrip
SET descrip= LTRIM(descrip,SUBSTRING(descrip,0,10));

Msg 174, level 15 State 1
the function 'ltrim' requires 1 argument

Suggestions?|||You are using MS SQL Server 2000.

update table
set column = Right(column, Len(column) - 1)

- From Visual Basic|||No, I am using
SQL 6.5...sql

Thursday, March 22, 2012

Delayed Write Failed

Hello,
We met a problem when we want to backup our database to a shared disk, the
error message is as following,
{Delayed Write Failed} Windows was unable to save all the data for the file
\Device\MysharedDriver. The data has been lost. This error may be caused by
a failure of your computer hardware or network connection. Please try to
save this file elsewhere.
But we succeeded with backup the pubs database to the same folder in the
shared disk.
Please anyone give help.
Thanks
FrankI think you do not have enough space to save Backup file.
first step:You must sure you have enough disk for your
database.
Second Step:Check the right of Sql Server's SA,how much
disk space SA can used on the shaved disk.
Good luck.
Milton Li
>--Original Message--
>Hello,
>We met a problem when we want to backup our database to
a shared disk, the
>error message is as following,
>{Delayed Write Failed} Windows was unable to save all
the data for the file
>\Device\MysharedDriver. The data has been lost. This
error may be caused by
>a failure of your computer hardware or network
connection. Please try to
>save this file elsewhere.
>But we succeeded with backup the pubs database to the
same folder in the
>shared disk.
>Please anyone give help.
>Thanks
>Frank
>
>.
>|||sometimes its also related to disk issues.
check there are no errors on disks by looking into
your system log.
>--Original Message--
>I think you do not have enough space to save Backup file.
>first step:You must sure you have enough disk for your
>database.
>Second Step:Check the right of Sql Server's SA,how much
>disk space SA can used on the shaved disk.
>Good luck.
>Milton Li
>>--Original Message--
>>Hello,
>>We met a problem when we want to backup our database to
>a shared disk, the
>>error message is as following,
>>{Delayed Write Failed} Windows was unable to save all
>the data for the file
>>\Device\MysharedDriver. The data has been lost. This
>error may be caused by
>>a failure of your computer hardware or network
>connection. Please try to
>>save this file elsewhere.
>>But we succeeded with backup the pubs database to the
>same folder in the
>>shared disk.
>>Please anyone give help.
>>Thanks
>>Frank
>>
>>.
>.
>

Wednesday, March 7, 2012

Deferrend Name Resolution for a field in a Stored Procedure

We are doing an upgrade in about a month and changing the account structure
in one of our tables. I am trying to write a routine that will check to see
if we are using the old format or the new format. So I wrote the following
stored procedure:
CREATE PROCEDURE [dbo].[sp_Account_Info] AS
if exists(select COLUMN_NAME = convert(sysname,name) from syscolumns where
name ='ACTNUMBR_6')
begin
select ACTNUMBR_5,ACTNUMBR_6 from Account_Table
--Do more stuff
end
else
begin
select ACTNUMBR_4 from Account_Table
--Do more stuff
end
In the old format the columns stop at ACTUNUMBR_4, but in the new table
structure(Which has not been implmented yet) we will be adding ACTNUMBR_5
and ACTNUMBR_6. The problem I am having is SQLServer will not let me save
this stored procedure because it says I have an invalid column name. Is
there a way to save the stored procedure even though the new columns do not
yet exist?You could use dynamic SQL (www.sommarskog.se), but perhaps you should consid
er a stable data model
instead, which doesn't require you to add columns over time.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Miles C" <mcousens@.clearwater.ca> wrote in message news:eZmKRAHlGHA.408@.TK2MSFTNGP03.phx.g
bl...
> We are doing an upgrade in about a month and changing the account structur
e in one of our tables.
> I am trying to write a routine that will check to see if we are using the
old format or the new
> format. So I wrote the following stored procedure:
> CREATE PROCEDURE [dbo].[sp_Account_Info] AS
> if exists(select COLUMN_NAME = convert(sysname,name) from syscolumns where
name ='ACTNUMBR_6')
> begin
> select ACTNUMBR_5,ACTNUMBR_6 from Account_Table
> --Do more stuff
> end
> else
> begin
> select ACTNUMBR_4 from Account_Table
> --Do more stuff
> end
> In the old format the columns stop at ACTUNUMBR_4, but in the new table st
ructure(Which has not
> been implmented yet) we will be adding ACTNUMBR_5 and ACTNUMBR_6. The pro
blem I am having is
> SQLServer will not let me save this stored procedure because it says I hav
e an invalid column
> name. Is there a way to save the stored procedure even though the new col
umns do not yet exist?
>