sql-server-2008-r2

Simulate a table with multiple rows just with SELECT statement

。_饼干妹妹 提交于 2020-01-03 08:44:10
问题 If I can do the following select statement to create a table with one value SELECT 'myname' AS 'Name' this will return a table with column = Name and one value = myname how can I work around this to return one column with multiple values from just the select statement I don't want to do this : DECLARE @tmp TABLE (Name varchar(50)) INSERT INTO @tmp (Name) VALUES ('myname1'),('myname2') SELECT * FROM @tmp Just from a single SELECT statement if possible 回答1: If you're wanting to simulate a table

SQL Server Default Database when Query - master

僤鯓⒐⒋嵵緔 提交于 2020-01-03 06:58:04
问题 I've been using SQL Server Management Studio (SSMS) for the last 8 years, and I keep on stumbling upon a problem. When I right click on a Table, and select SELECT TOP 2000 ROWS, the query editor opens up a new file with the query inside. This is nice and all for a quick review of the table. The problem I have is the default database is changed from the actual database to the master database. I have sysadmin rights. The query that gets generated by SSMS, then has the databse, schema, and table

Preventing update loops for multiple databases using CDC

 ̄綄美尐妖づ 提交于 2020-01-03 06:32:12
问题 We have a number of legacy systems that we're unable to make changes to - however, we want to start taking data changes from these systems and applying them automatically to other systems. We're thinking of some form of service bus (no specific tech picked yet) sitting in the middle, and a set of bus adapters (one per legacy application) to translate between database specific concepts and general update messages. One area I've been looking at is using Change Data Capture (CDC) to monitor

extract a string from a stored proc definition

泪湿孤枕 提交于 2020-01-03 05:29:06
问题 I need to check the library used by several stored procs that extract data from a remote server. I have (with SO help, see SO 21708681) built the below code: DECLARE @tProcs TABLE ( procID int IDENTITY, procObjectID nvarchar(100), procName nvarchar(100) ); insert into @tProcs SELECT object_id, name FROM sys.objects WHERE type in (N'P', N'PC') and name like '%_Extract' declare @countProcs int, @I int=0 select @countProcs=COUNT(*) from @tProcs while @I<@countProcs Begin declare @source_code

Refreshing DataGridView from another form on button click

落花浮王杯 提交于 2020-01-03 04:43:12
问题 I want to refresh the DataGridView after inserting a new member into the database. I created a method on the main form which occurs on the mainform_load. From the other form (addmember), after I click on SaveMemberButton I'm calling that method to refresh the datagridview but It wont happen. This is my code on the main form: private void MainForm_Load(object sender, EventArgs e) { //ShowLoginForm(); ListMembers(); } public void ListMembers() { MembersDataGridView.Columns.Clear();

“CREATE DATABASE permission denied” error

非 Y 不嫁゛ 提交于 2020-01-02 07:45:30
问题 I have installed SQL SERVER 2008 R2 on my system with Windows XP operating system installed. Whenever I try to create a new database it displays an error: CREATE DATABASE PERMISSION DENIED IN DATABASE 'master'.(Microsoft SQL Server, Error:262) 回答1: When you start SQL server management studio use 'sa' user and not Windows-User. Looks like Windows-user does not have permission. 回答2: Right-click and run "SQL Server Management Studio" as administrator. 回答3: Try to grant the user your loged in the

“Between” operator generating bad query plan when using parameters

心不动则不痛 提交于 2020-01-02 06:35:12
问题 I have a simple dates table (Date, DateID) which contains a list of dates between 1-Jan-1900 and 31-Dec-2100. When selecting from the table using the between operator and hard-coded parameter values, I get a correct query plan with 3 estimated rows compared to 2 actual rows: select v.Date from Dates v where v.Date between '20130128' and '20130129'; However when replacing the hard-coded values with parameters, the query plan changes to a very poor plan, with over 6000 estimated rows and only 2

Why is SSDT Schema Compare showing difference in DefaultExpressionScript?

為{幸葍}努か 提交于 2020-01-02 04:31:11
问题 While comparing Database instance to a Database project in VS2010 using SSDT, it shows a difference in one of the Stored Procedures. The Store Procedure DDL script is exactly the same but when I expanded the Properties folder under the Store Procedure it show a difference in the DefaultExpressionScript. The source SP shows this in the DefaultExpresionScript: DefaultExpressionScript = at While the destination SP has this: DefaultExpressionScript = -1 I don't see where I can change this there

Getting the error “Data retrieval failed for the subreport, 'Subreport1'” while trying to preview a report from Business Intelligence Studio

大憨熊 提交于 2020-01-02 03:47:04
问题 I know this question has been asked before, but all questions were for reports being accessed using C# or vb.net code. My problem is that i am building and accessing the report using Business Intelligence studio, I am basically trying to add a sub report for a report, and I made sure from the parameters and they are ok. However when i try to access the report containing the subreport, I get the error "Data retrieval failed for the subreport, 'Subreport1'". I also tried deleting the .data

Deadlock issue in SQL Server 2008 R2 (.Net 2.0 Application)

 ̄綄美尐妖づ 提交于 2020-01-02 02:53:30
问题 The Sql Server 2008 R2 instance in question is a heavy load OLTP production server. The deadlock issue came up a few days back and is still unresolved. We received the Xml deadlock report that listed the stored procedures involved in the deadlock and some other details. I'll try to list down the facts from this xml first: Two stored procedures are involved in the deadlock, say SP1 and SP2. According to the report SP1 was running in Isolation level "Serializable" and SP2 was running in