Posted: 8/27/2010
I have one Database A .mdf
now i want to create Database B.mdf just like Database A
I generated a script of Database A .mdf
and created fresh Database B.mdf
Now, when i try to run the generated script against Database B, i get this error, why ? how to fix it ?
For your information:
I am using Visual Studio 2008 ...
I have checked in my script it is:
SET ANSI_NULLS ONGO
and i have also tried to save the sql script in notepad as: ANSI, UTF-8 and UNICODE
and then i copied from txt file to query but still doesn't work and getting the same error
and these are the option that i selected/used while creating my script:
Mike,
Why don't you go for Copy Database Wizard
Hello, raghav,
as i mentioned above i am using Visual Studio, i don't have SQL Server Management studio
Can you show your script ?
I think your script might be like this :
SELECT * FROM TABLE1 GO SELECT * FROM TABLE2 GO SELECT * FROM TABLE3 GO SELECT * FROM TABLE4 GO
#region Using Directives using System; using System.Collections.Generic; using System.Data.SqlClient; using System.IO; using System.Text; #endregion public class Example { class Test { static void Main() { AddLineBreaks("D:\\test.sql"); } private static void AddLineBreaks(string path) { // Open a file for reading StreamReader streamReader = File.OpenText(path); // Now, read the entire file into a strin string contents = streamReader.ReadToEnd(); streamReader.Close(); // Write the modification into the same fil StreamWriter streamWriter = File.CreateText(path); streamWriter.Write(contents.Replace("GO", "\r\nGO\r\n")); streamWriter.Close(); } } }
Posted: 8/28/2010
Hello raghav,
thanks for writing that sample problem for me but the problem is my script is already like that:
my script is something like this:
****** Object: ForeignKey [FK__aspnet_Me__Appli__276EDEB3] Script Date: 08/27/2010 11:46:25 ******/IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Me__Appli__276EDEB3]') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Membership]'))ALTER TABLE [dbo].[aspnet_Membership] DROP CONSTRAINT [FK__aspnet_Me__Appli__276EDEB3]GO/****** Object: ForeignKey [FK__aspnet_Me__UserI__286302EC] Script Date: 08/27/2010 11:46:25 ******/IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Me__UserI__286302EC]') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Membership]'))ALTER TABLE [dbo].[aspnet_Membership] DROP CONSTRAINT [FK__aspnet_Me__UserI__286302EC]GO/****** Object: ForeignKey [FK__aspnet_Pa__Appli__59063A47] Script Date: 08/27/2010 11:46:25 ******/IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pa__Appli__59063A47]') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Paths]'))ALTER TABLE [dbo].[aspnet_Paths] DROP CONSTRAINT [FK__aspnet_Pa__Appli__59063A47]GO/****** Object: ForeignKey [FK__aspnet_Pe__PathI__5EBF139D] Script Date: 08/27/2010 11:46:25 ******/IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pe__PathI__5EBF139D]') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationAllUsers]'))ALTER TABLE [dbo].[aspnet_PersonalizationAllUsers] DROP CONSTRAINT [FK__aspnet_Pe__PathI__5EBF139D]GRANT EXECUTE ON [dbo].[aspnet_Membership_UnlockUser] TO [aspnet_Membership_FullAccess] AS [dbo]GOGRANT EXECUTE ON [dbo].[aspnet_Membership_UpdateUser] TO [aspnet_Membership_FullAccess] AS [dbo]GOGRANT EXECUTE ON [dbo].[aspnet_Membership_UpdateUserInfo] TO [aspnet_Membership_BasicAccess] AS [dbo]ENDGO
somebody told me to eliminate "GO" as i am using Visual Studio and GO is only for SQL server management studio
i evenr tried script by eliminating "Go" then i got this error:
Mike, I need to see your full SQL script.
Posted: 8/30/2010
Hello rajneesh, just wanted to give you a good news that i ran the script on SSMS 2005 on someone else's machine (as i don't have it) and it worked !!!
Can you help me with this issue ? i am trying to install SSMS 2008 and facing lot of problem, i have posted my issue here:
http://strivingprogrammers.com/boards/t/38/how-to-connect-to-local-instance-of-sql-server-2008-management-studio-express-.aspx
asp__developer said: user="Mike Williams"]Can you help me with this issue ? i am trying to install SSMS 2008 and facing lot of problem, i have posted my issue here:
user="Mike Williams"]Can you help me with this issue ? i am trying to install SSMS 2008 and facing lot of problem, i have posted my issue here:
Can you please post your new query as a new post on the forums here? It would benefit other CodeAsp.Net members too.
Thanks,
Vivek
[quote user="Vivek Thakur"]
[/quote]
Hello vivek, here it is:
http://www.codeasp.net/forums/asp-net-topics/data-access/517/how-to-connect-to-local-instance-of-sql-server-2008-management-studio-express
Posted: 9/1/2010
@Mike, can you please close this thread. As far as I've seen, the issue is resolved :).