sql-server-2005

How to migrate a database from SQL Server 2005 to 2008 as is?

情到浓时终转凉″ 提交于 2020-01-04 04:35:09
问题 I want to migrate a database completely or partially. Right now, I will do a complete database. Partial will be posted as a separate question. Strategies I am considering: copy database wizard convert 2005 database to script. Run script on 2008 simple SQL query My question - I want to use method 2. Is it even possible to do this? If yes, how to do it? Any limitations/risks ? NOTE - The source server is a SQL Server 2005 database with one IP. Destination is a SQL Server 2008 instance with

How to migrate a database from SQL Server 2005 to 2008 as is?

时光毁灭记忆、已成空白 提交于 2020-01-04 04:35:07
问题 I want to migrate a database completely or partially. Right now, I will do a complete database. Partial will be posted as a separate question. Strategies I am considering: copy database wizard convert 2005 database to script. Run script on 2008 simple SQL query My question - I want to use method 2. Is it even possible to do this? If yes, how to do it? Any limitations/risks ? NOTE - The source server is a SQL Server 2005 database with one IP. Destination is a SQL Server 2008 instance with

Using the dangerous IN clause in SQL

天涯浪子 提交于 2020-01-04 04:10:14
问题 Why does SQL server behave this way. I am running this on SQL 2005. The IN clause does not validate the column names in the sub query but validates it against the table name in the outer query. Here is an example of getting Create table #table1(col1 int, col2 char(10), col3 char(15)); Create table #table2(col10 int, col11 char(10), col2 char(15)); insert into #table1(col1, col2, col3) select 1, 'one', 'three' insert into #table1(col1, col2, col3) select 2, 'two', 'three' insert into #table1

How can I query the database culture (SQL Server 2005)?

这一生的挚爱 提交于 2020-01-04 02:02:13
问题 How can I query the database culture (SQL Server 2005) ? I have problems inserting and getting dates, because the client's servers don't run on the same culture as my developer server. I can adjust the date, but I need to know the server's culture... 回答1: You can find out about the currently configured language using this: SELECT @@language and you might also want to check out this: EXEC sp_helplanguage It will show the available languages, and what date formats etc. they have. This is

lu.[TableName] instead of dbo.[TableName]?

三世轮回 提交于 2020-01-04 01:39:52
问题 Some of the tables in my SQL Server 2005 database is named as lu.[TableName] instead of dbo.[TableName]. What does lu stand for? Note: I tried google already 回答1: That would be a schema in SQL Server 2005 - which you can create yourself using CREATE SCHEMA. A schema can be used to separate out database objects that logically belong together, e.g. put all tables related to human resources into a "HR" schema etc. DB Schemas are a bit like .NET or XML namespaces. A schema can also be used to

How to traverse through a table which has relation to itself?

戏子无情 提交于 2020-01-04 01:07:20
问题 I have a table like the following Node_Id Node_Name Parent_Node_Id ------- --------- -------------- 1 Root 0 2 Node1 1 3 Node2 1 4 Node3 2 5 Node4 2 6 Node5 5 7 Node6 5 8 Node7 7 Each row of the table has a parent row which is indicated by the "Parent_Node_Id" and each row/node can be parent of any number of row/nodes. How can I write a query which will give me the list of all nodes who have a parent node who all share the same parent node? The Parent_Node_Id will be passed as the parameter.

HRESULT: 0x8004D00E using TransactionScope - C#

随声附和 提交于 2020-01-03 19:14:21
问题 I received the following error when I tried to run a C# WinForms application on a Windows Server 2003 Standard Edition SP1 machine that was connecting to a SQL server 2000, converting the data in the WinForms app and inserting the converted into a SQL server 2005 application. I am connecting to each database using SSPI. The code was contained within a TransactionScope block: System.TimeSpan TransactionTimeOut = new TimeSpan(0, 40, 0); using(TransactionScope Scope = new TransactionScope

Group by with 2 distinct columns in SQL Server

混江龙づ霸主 提交于 2020-01-03 19:07:08
问题 I have data like below ID Stat Date 1 1 2009-06-01 2 1 2009-06-20 3 1 2009-06-10 4 2 2009-06-10 O/P to be like this.. ID Stat CDate 2 1 2009-06-20 4 2 2009-06-10 I have tried with below query and was unsuccessful, please suggest. Select Distinct stat,MAX(Cdate) dt,id From testtable Group By stat,id Got the solution.. Select f1.id,f1.stat,f1.cdate From testtableas F1 Join(Select stat,MAX(cdate) as dt from testtable group by stat) as F2 On f2.stat=F1.stat and f2.dt=f1.cdate 回答1: SELECT t1.id,

Group by with 2 distinct columns in SQL Server

丶灬走出姿态 提交于 2020-01-03 19:06:30
问题 I have data like below ID Stat Date 1 1 2009-06-01 2 1 2009-06-20 3 1 2009-06-10 4 2 2009-06-10 O/P to be like this.. ID Stat CDate 2 1 2009-06-20 4 2 2009-06-10 I have tried with below query and was unsuccessful, please suggest. Select Distinct stat,MAX(Cdate) dt,id From testtable Group By stat,id Got the solution.. Select f1.id,f1.stat,f1.cdate From testtableas F1 Join(Select stat,MAX(cdate) as dt from testtable group by stat) as F2 On f2.stat=F1.stat and f2.dt=f1.cdate 回答1: SELECT t1.id,

How to execute sp_send_dbmail while limiting permissions

吃可爱长大的小学妹 提交于 2020-01-03 18:32:09
问题 Is there a way to provide access to users in my database to execute msdb.dbo.sp_send_dbmail without needing to add them to the MSDB database and the DatabaseMailUserRole? I've tried this: ALTER PROCEDURE [dbo].[_TestSendMail] ( @To NVARCHAR(1000), @Subject NVARCHAR(100), @Body NVARCHAR(MAX) ) WITH EXECUTE AS OWNER AS BEGIN EXEC msdb.dbo.sp_send_dbmail @profile_name = N'myProfile', @recipients = @To, @subject = @Subject, @body = @Body END But I get this error: The EXECUTE permission was denied