Sunday, March 25, 2012

Changing the day of week in SQL Server 2000

Dear All,

I have one field in my table which shows the day of the week. It is
showing

Sunday = 1
Monday = 2
Tuesday = 3

But i want Monday is the first day. I know i can use DATEFIRST to
change it but it works in Query Analyzerbut when i come and see my
table it is showing the old settings. Is it possible i can change it
permanently. Any help in this regard will be higly appreciated

Regards

SHi Neha

It is not clear what you are trying to do or how your data is being held,
posting DDL (create table statements) and example data (as insert
statements) will remove any ambiguity
http://www.aspfaq.com/etiquette.asp?id=5006

If the day of the week in your table is data it will need to be updated. If
it is currently held as a value 1-7
with Sunday = 1... then try the statement

UPDATE MyTable
SET DayOfWeek = CASE WHEN DayOfWeek = 1 THEN 7 ELSE DayOfWeek - 1 END

Using SET DATEFIRST will change the settings for the current session,
therefore you will need to make sure it is set currectly before issuing your
statement. Alternatively datefirst can be change if a different default
language is specified, to check the current language use sp_helplanguage
@.@.LANGUAGE. sp_helplanguage with no parameters will show you what the values
are for each language. To change the default language use sp_configure (see
Books online for more information)

John

"Neha" <newlooks4u@.hotmail.com> wrote in message
news:76c8ae2c.0412220555.4f0326d@.posting.google.co m...
> Dear All,
> I have one field in my table which shows the day of the week. It is
> showing
> Sunday = 1
> Monday = 2
> Tuesday = 3
> But i want Monday is the first day. I know i can use DATEFIRST to
> change it but it works in Query Analyzerbut when i come and see my
> table it is showing the old settings. Is it possible i can change it
> permanently. Any help in this regard will be higly appreciated
> Regards
> S|||John Bell (jbellnewsposts@.hotmail.com) writes:
> Using SET DATEFIRST will change the settings for the current session,
> therefore you will need to make sure it is set currectly before issuing
> your statement. Alternatively datefirst can be change if a different
> default language is specified, to check the current language use
> sp_helplanguage @.@.LANGUAGE. sp_helplanguage with no parameters will show
> you what the values are for each language. To change the default
> language use sp_configure (see Books online for more information)

What you change with sp_configure is the default language for new
logins.

To change the default language for an existing login, use
sp_defaultlanguage.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

No comments:

Post a Comment