Showing posts with label leave. Show all posts
Showing posts with label leave. Show all posts

Wednesday, March 7, 2012

ALTER DATABASE MODIFY NAME but

Leave the file location/directory the heck alone!

How do I do this?

Just issuing:

ALTER DATABASE Old_Name MODIFY NAME = New_Name

moves the mdf and ldf files to a new, unwanted location (apparently the SQL Server default as it's under program files) with the new name.

Is this possible or do I have to issue the additional ALTER DATABASE MODIFY FILE statements for this?modify name does not move the file(s).

create database [test]
on(name=test,filename='c:\test.mdf')
log on(name=test_log,filename='c:\test.ldf')
go
alter database [test] modify name=newtest
go
select *
from [newtest]..sysfiles
go
drop database [newtest]
go

==result==
1 test c:\test.mdf
2 test_log c:\test.ldf|||

Hi,

ALTER DATABASE ... MODIFY FILE command modifies the names of data files of the related database.

Please check the following article for also a sample on changing logical file names of SQL databases http://www.kodyaz.com/articles/change-sql-server-database-file-names.aspx

Eralper

|||Guess you didn't read my full post. I'm aware of this command.|||did you try my demo script. do you get the expected result?|||

Yeah, turns out it's not that part of the script but rather the Copy Database wizard that is to blame.

(I've got a post in tools on it bu gtno replies yet.)

Sunday, February 19, 2012

Allowing for blank fields in date text boxes

Several textboxes are being on a web form for date entry. and we want to allow the user to leave date fields blank (if particular date is unknown). However, when the field is left blank, the SQL Server 2000 database defaults to 1/1/1900 (datatype = datetime).
My question is as follows: How is it possible to leave a date textbox field blank, and either send 00\00\0000 or spaces to the SQL Server 2000 database datetime field?
Any advice/insight is appreciated! RobEDIT
Both Datetime and SmallDatetime allow NULLs Datetime is 8bytes while Smalldatetime is 4bytes but its resolution is limited. If you want Time Span you have to use DateTime.
when you are using NULL with Datetime you must use COUNT (*) in all you calculations because all SQL Server aggregate functions ignore NULLs except COUNT (*).
Hope this helps.|||Check outthis article