Showing posts with label sqlserver. Show all posts
Showing posts with label sqlserver. Show all posts

Friday, March 30, 2012

How to change the default database folder

When we restore an .bak to SqlServer 2005, it will place the .mdb file in
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
How can I change this default database folder?By default the restore database command will try to restore the database
files to their original locations when the database was backed up. If you ar
e
using Management Studio on the Restore Database window select the Options ta
b
and update the 'Restore As' section as needed.
If you already restored the database you can still move the files to some
other location by using, for example, detach, move the database files and th
e
attach the database again.
Hope this helps,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"ad" wrote:

> When we restore an .bak to SqlServer 2005, it will place the .mdb file in
> C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
> How can I change this default database folder?
>
>|||You can change default database locations setting from SSMS. Go to Instance'
s Server Properties\Database Settings. There, you'll see "Database default
locations" at the bottom of the window.
Ekrem nsoy
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:ud5iIjINIHA.5040@.TK2MSFTNGP04.phx.gbl...
> When we restore an .bak to SqlServer 2005, it will place the .mdb file in
> C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
> How can I change this default database folder?
>

How to change the default database folder

When we restore an .bak to SqlServer 2005, it will place the .mdb file in
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
How can I change this default database folder?By default the restore database command will try to restore the database
files to their original locations when the database was backed up. If you are
using Management Studio on the Restore Database window select the Options tab
and update the 'Restore As' section as needed.
If you already restored the database you can still move the files to some
other location by using, for example, detach, move the database files and the
attach the database again.
Hope this helps,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"ad" wrote:
> When we restore an .bak to SqlServer 2005, it will place the .mdb file in
> C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
> How can I change this default database folder?
>
>|||You can change default database locations setting from SSMS. Go to Instance'
s Server Properties\Database Settings. There, you'll see "Database default
locations" at the bottom of the window.
--
Ekrem Önsoy
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:ud5iIjINIHA.5040@.TK2MSFTNGP04.phx.gbl...
> When we restore an .bak to SqlServer 2005, it will place the .mdb file in
> C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
> How can I change this default database folder?
>

How to change the default database folder

When we restore an .bak to SqlServer 2005, it will place the .mdb file in
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
How can I change this default database folder?
By default the restore database command will try to restore the database
files to their original locations when the database was backed up. If you are
using Management Studio on the Restore Database window select the Options tab
and update the 'Restore As' section as needed.
If you already restored the database you can still move the files to some
other location by using, for example, detach, move the database files and the
attach the database again.
Hope this helps,
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"ad" wrote:

> When we restore an .bak to SqlServer 2005, it will place the .mdb file in
> C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
> How can I change this default database folder?
>
>
|||You can change default database locations setting from SSMS. Go to Instance'
s Server Properties\Database Settings. There, you'll see "Database default
locations" at the bottom of the window.
Ekrem nsoy
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:ud5iIjINIHA.5040@.TK2MSFTNGP04.phx.gbl...
> When we restore an .bak to SqlServer 2005, it will place the .mdb file in
> C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
> How can I change this default database folder?
>

Monday, March 26, 2012

How to change Name Server/instance?

I've change the computer's name. So my SQLServer doesn't work. Now, How to
change Name Server/instance? So my SQLServer can work again.> I've change the computer's name. So my SQLServer doesn't work. Now, How to
> change Name Server/instance? So my SQLServer can work again.
http://www.karaszi.com/sqlserver/in...server_name.asp
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com|||hi
For this, u need to drop the existing server
sp_dropserver '<old server>'
and add a new server name. do not forget to add the reserved word "local'
sp_addserver '<new server>', 'local'
please let me know if u have any questions
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"Bpk. Adi Wira Kusuma" wrote:

> I've change the computer's name. So my SQLServer doesn't work. Now, How to
> change Name Server/instance? So my SQLServer can work again.
>
>sql

Friday, March 23, 2012

How to change encoding for XML Column

I am updating an xml column in SQLServer 2005, but it always gives me
an error
"XML parsing: line 1, character 38, unable to switch the encoding"
my csharp is like the following
cmd.Parameters.Add("@.xml", SqlDbType.Xml);
cmd.Parameters["@.xml"].Value =xmldata;
My xml have the following line
"<?xml version="1.0" encoding="UTF-8"?>..."
If I remove this line, everything is OK, looks like the SQLParameter is
set to UTF-16 and my xml data is set to UTF-8, how do I make
SQLParameter take UTF-8? I did not see any properties under
SQLParameter to change the encode.
Please advice.
Thanks in advance.
JohnWell I do search a bit and perhaps you want to remove that line before you
insert it in to the column.
chanmm
"John" <johnxhc@.yahoo.com> wrote in message
news:1149546544.618008.58060@.i39g2000cwa.googlegroups.com...
>I am updating an xml column in SQLServer 2005, but it always gives me
> an error
> "XML parsing: line 1, character 38, unable to switch the encoding"
> my csharp is like the following
> cmd.Parameters.Add("@.xml", SqlDbType.Xml);
> cmd.Parameters["@.xml"].Value =xmldata;
> My xml have the following line
> "<?xml version="1.0" encoding="UTF-8"?>..."
> If I remove this line, everything is OK, looks like the SQLParameter is
> set to UTF-16 and my xml data is set to UTF-8, how do I make
> SQLParameter take UTF-8? I did not see any properties under
> SQLParameter to change the encode.
> Please advice.
> Thanks in advance.
> John
>|||Try using SqlDbType.VarChar (even if your parameter in the proc is really
XML). This worked for me. Reason is likely that you're using a System.String
(Unicode) and the XML data type is internally UTF-16, so telling it UTF-8 is
switching encodings, after its "decided" you wanted UTF-16. There is
automatic string conversion if the encoding matches the SQL varchar data
type.
Bear in mind, you'll always get the data out as UTF-16.
Cheers,
Bob Beauchemin
http://www.SQLskills.com/blogs/bobb
"John" <johnxhc@.yahoo.com> wrote in message
news:1149546544.618008.58060@.i39g2000cwa.googlegroups.com...
>I am updating an xml column in SQLServer 2005, but it always gives me
> an error
> "XML parsing: line 1, character 38, unable to switch the encoding"
> my csharp is like the following
> cmd.Parameters.Add("@.xml", SqlDbType.Xml);
> cmd.Parameters["@.xml"].Value =xmldata;
> My xml have the following line
> "<?xml version="1.0" encoding="UTF-8"?>..."
> If I remove this line, everything is OK, looks like the SQLParameter is
> set to UTF-16 and my xml data is set to UTF-8, how do I make
> SQLParameter take UTF-8? I did not see any properties under
> SQLParameter to change the encode.
> Please advice.
> Thanks in advance.
> John
>

Wednesday, March 21, 2012

How to change Database name in SQLServer?

I want to change some Databases' name. But the only way I know is backup the
database, and change another name when recovering it. Is there any other way
that is easier than that below? thanks
zlf
You can do it using ALTER DATABASE
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"news.microsoft.com" <zlfcn@.hotmail.com> wrote in message
news:OsHwjN4LFHA.3500@.TK2MSFTNGP14.phx.gbl...
>I want to change some Databases' name. But the only way I know is backup the
> database, and change another name when recovering it. Is there any other way
> that is easier than that below? thanks
> zlf
>
|||Thank you!
zlf
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> д?
news:#vyABZ4LFHA.3852@.tk2msftngp13.phx.gbl...[vbcol=seagreen]
> You can do it using ALTER DATABASE
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "news.microsoft.com" <zlfcn@.hotmail.com> wrote in message
> news:OsHwjN4LFHA.3500@.TK2MSFTNGP14.phx.gbl...
the[vbcol=seagreen]
way
>
|||sp_renamedb
"news.microsoft.com" wrote:

> I want to change some Databases' name. But the only way I know is backup the
> database, and change another name when recovering it. Is there any other way
> that is easier than that below? thanks
> zlf
>
>

How to change Database name in SQLServer?

I want to change some Databases' name. But the only way I know is backup the
database, and change another name when recovering it. Is there any other way
that is easier than that below? thanks
zlfYou can do it using ALTER DATABASE
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"news.microsoft.com" <zlfcn@.hotmail.com> wrote in message
news:OsHwjN4LFHA.3500@.TK2MSFTNGP14.phx.gbl...
>I want to change some Databases' name. But the only way I know is backup the
> database, and change another name when recovering it. Is there any other way
> that is easier than that below? thanks
> zlf
>|||Thank you!
zlf
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> дÈëÏûÏ¢
news:#vyABZ4LFHA.3852@.tk2msftngp13.phx.gbl...
> You can do it using ALTER DATABASE
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "news.microsoft.com" <zlfcn@.hotmail.com> wrote in message
> news:OsHwjN4LFHA.3500@.TK2MSFTNGP14.phx.gbl...
> >I want to change some Databases' name. But the only way I know is backup
the
> > database, and change another name when recovering it. Is there any other
way
> > that is easier than that below? thanks
> >
> > zlf
> >
> >
>|||sp_renamedb
"news.microsoft.com" wrote:
> I want to change some Databases' name. But the only way I know is backup the
> database, and change another name when recovering it. Is there any other way
> that is easier than that below? thanks
> zlf
>
>

How to change Database name in SQLServer?

I want to change some Databases' name. But the only way I know is backup the
database, and change another name when recovering it. Is there any other way
that is easier than that below? thanks
zlfYou can do it using ALTER DATABASE
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"news.microsoft.com" <zlfcn@.hotmail.com> wrote in message
news:OsHwjN4LFHA.3500@.TK2MSFTNGP14.phx.gbl...
>I want to change some Databases' name. But the only way I know is backup th
e
> database, and change another name when recovering it. Is there any other w
ay
> that is easier than that below? thanks
> zlf
>|||Thank you!
zlf
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> д?
news:#vyABZ4LFHA.3852@.tk2msftngp13.phx.gbl...
> You can do it using ALTER DATABASE
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "news.microsoft.com" <zlfcn@.hotmail.com> wrote in message
> news:OsHwjN4LFHA.3500@.TK2MSFTNGP14.phx.gbl...
the[vbcol=seagreen]
way[vbcol=seagreen]
>|||sp_renamedb
"news.microsoft.com" wrote:

> I want to change some Databases' name. But the only way I know is backup t
he
> database, and change another name when recovering it. Is there any other w
ay
> that is easier than that below? thanks
> zlf
>
>sql

Friday, March 9, 2012

How to call a stored procedure on MS Sqlserver from web forms and get back output

Hi,

How to call a stored procedure on MS Sqlserver from web forms and get back output

Thanx,

Nishu

Within the blue navigation bar at the top of this website, you will see a link to theASP.NET Tutorials. There you will find a large number of tutorials aboutPerforming Data Access.

While you are new to ASP.NET, you should find that most of your questions will be answered--with code samples--inside the Tutorials. Please keep them in mind.

Friday, February 24, 2012

How to by pass this error message

Hi,

I am trying to import transfer data from one database(sqlserver) to another database(sqlserver)...

But when i run the stored procedure... it gives me the following error

Msg 2627, Level 14, State 1, Procedure usp_ImportFunds_Growthof10K, Line 36

Violation of PRIMARY KEY constraint 'PK_Growthof10K'. Cannot insert duplicate key in object 'Growthof10K'.

and this is my sproc

Code Snippet

USE [StageFiserv_Dev]

GO

/****** Object: StoredProcedure [dbo].[usp_ImportFunds_Growthof10K] Script Date: 08/10/2007 12:53:48 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER Procedure [dbo].[usp_ImportFunds_Growthof10K]

AS

BEGIN

DECLARE @.Count int

SET NOCOUNT ON;

UPDATE Fiserv_Dev..Growthof10K

SET

ChartHeader = g.ChartHeader,

Dates = Substring(g.Dates,1,9),

NAV = g.NAV,

LastChangeDate = GetDate()

FROM

Fiserv_Dev..Growthof10K gk

Join [Growth] g ON gk.Cusip = g.Cusip

Where

gk.ChartHeader <> g.ChartHeader

OR

gk.Dates <> Substring(g.Dates,1,9)

OR

gk.NAV <> g.NAV

SET @.Count = @.@.ROWCOUNT

IF @.Count > 0

RAISERROR('Updated %d records(s) in Growthof10K.', 0, 1, @.Count) WITH NOWAIT

ELSE

RAISERROR('No changes made Growthof10K.', 0, 1) WITH NOWAIT

RAISERROR('Adding records to Growthof10K.',0,1) With NOWAIT

INSERT INTO Fiserv_Dev..Growthof10K

(

Cusip,

ChartHeader,

Dates,

NAV

)

SELECT

g.Cusip,

g.ChartHeader,

Substring(g.Dates,1,9),

g.NAV

FROM

Growth g

Where

NOT Exists (

Select *

FROM

Fiserv_Dev..Growthof10K gk

Where

gk.Cusip = g.Cusip

)

SET @.Count = @.@.ROWCOUNT

IF @.Count > 0

RAISERROR('Added %d records(s) to Growthof10K table.', 0, 1, @.Count) WITH NOWAIT

ELSE

RAISERROR('No records added to Growthof10K table.', 0, 1) WITH NOWAIT

SET NOCOUNT OFF

END

There around 763 records in the growth table

Can some one please help me.

Regards,

Karen

Karen

You are inserting a duplicate value in a primary key. You can't do that. Delete the duplicate values for the primary key field or remove the primary key constraint.

|||

thanks...|||

Did this solve your problem? If so then please mark it as answer.

Sunday, February 19, 2012

How to browse the history login detail of sqlserver?

Hi all,
I want to ask how to browse the history login detail of
sqlserver.eg:login user name , client ip and login time
thx.Hi
SQL server does not store it, unless you log it specifically though code
into a table.
If you have full auditing on, you can see the date and time of a specific
login (success or failure).
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"zlf" <zlfcn@.hotmail.com> wrote in message
news:Oj$X$xOLFHA.1916@.TK2MSFTNGP12.phx.gbl...
> Hi all,
> I want to ask how to browse the history login detail of
> sqlserver.eg:login user name , client ip and login time
> thx.
>|||Thank you for your help
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> д?:uGD9k3OLFHA.1176@.TK2MSFTNGP12.phx
.gbl...
> Hi
> SQL server does not store it, unless you log it specifically though code
> into a table.
> If you have full auditing on, you can see the date and time of a specific
> login (success or failure).
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "zlf" <zlfcn@.hotmail.com> wrote in message
> news:Oj$X$xOLFHA.1916@.TK2MSFTNGP12.phx.gbl...
>