sql-server-2005

SQL Server 2005 mdf file on 2012

核能气质少年 提交于 2019-12-12 04:37:22
问题 I have a SQL Server 2005 .mdf file I need to install on a server. Can I simply install SQL Server 2012 Express and attach the .mdf file without any issues, or should I stick to 2005 Express to eliminate any issues that may arise? I should also add it needs to support a ASP.NET 3.5 website. Cheers 回答1: If you have all files (mdf, ldf and potentially multiple ndf) and the database was cleanly shut down, you won't have an issue attaching to 2012. If you have only the mdf it might work but it

Query to get sum of an employees commission

孤者浪人 提交于 2019-12-12 04:34:11
问题 Query to get total commissions for an employee, and update their totalCommission column in the employee table. This query is run every few days (batch). The rules: 1. an employee can only get a maximum of $100/day of commision , if they get more than $100 it just gets set to $100. Tables: Employee (employeeID INT PK, totalCommissions INT, username, ...) Sale (saleID INT PK, employeeID INT FK, saleTotal, commission, created DATETIME) Using SQL Server 2005. So this query will have to group by

How to deploy C# windows application (setup file) with database and how to manage connection string on client machine

我只是一个虾纸丫 提交于 2019-12-12 04:32:01
问题 I am creating C# Windows Application in Visual Studio 2015 . Question: How to deploy C# Windows Application (setup file) with SQL Server database with database connection string. I create common connection string in app.config : <connectionStrings> <add name="conString" providerName="System.Data.sqlclient" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename= 'C:\Users\DEVELOPERS\Documents\Visual Studio 2015\Projects\Provision1\ Provision1\provision1.mdf';Integrated Security

Dividing a string into two parts and selecting into two variables

Deadly 提交于 2019-12-12 04:28:35
问题 I am using SQL Server 2005. I have a string with a special character : like: XYZ:xyz@mail.com I want to divide this string into two sub-strings and select into variables. The special character : is just a separator. @variable1=XYZ @variable2=xyz@mail.com Please guide me on how it is possible. 回答1: String Dividing Guide: Use CHARINDEX to find the position of : . Use SUBSTRING to grab all the characters before the position of : , and put them into @variable1 . Use SUBSTRING to grab all the

How do I create a table in SQL Server 2005?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 04:22:43
问题 I want to create a table called quiz_mailing_list in my database in SQL Server 2005. With Fields: id auto-increment primary key email varchar(256) optIn tinyint referringEmail varchar(256) Here is what I tried: CREATE TABLE quiz_mailing_list( id int identity(1,1) primary key, email varchar(256), optIn bit referringEmail varchar(256)) I get this error: System.Data.SqlClient.SqlException: Incorrect syntax near 'referringEmail' How do I create a table in SQL Server 2005? 回答1: USE

how to get return value from procedure sql server 2005 to c#

懵懂的女人 提交于 2019-12-12 04:20:57
问题 CREATE PROCEDURE [dbo].[Code] @intEpmName NUMERIC, @strFailedEMPID VARCHAR(1000) output AS DECLARE @FailedCodes VARCHAR(1000) BEGIN ---- my logic where i need return the value SET @strFailedEMPID = @FailedCodes ----- END In the stored procedure above, I can send the value as "0" to @strFailedEMPID then to my procedure. However, when I return the value from my procedure, then to the same variable @strFailedEMPID I am sending the value as such: lsqlParam = new SqlParameter("@strFailedEMPID ",

Question regarding index

若如初见. 提交于 2019-12-12 04:12:26
问题 I have the following query: SELECT M.Col7, M.Col8, M.Col9, M.Col10 FROM [MyTable] M WHERE M.Col1 = COALESCE(@Col1, M.Col1) AND M.Col2 = COALESCE(@Col2, M.Col2) AND M.Col3 = COALESCE(@Col3, M.Col3) AND M.Col4 = COALESCE(@Col4, M.Col4) AND M.Col5 = COALESCE(@Col5, M.Col5) AND M.Col6 LIKE COALESCE(@Col6, M.Col6) +'%' I have a combined non clustered index on col7,8,9,10 columns. The query is running fine if I remove the where clause. But as soon as I put the where clause the query is taking long

combining resultset of many select queries

这一生的挚爱 提交于 2019-12-12 04:11:45
问题 I have four Select queries for four different tables, each extracting only one record. For example: Select * from table where col1 = 'something' gives one row having 3 columns. The second select query also gives one record having two columns(fields). Same for third and fourth select query. I want to combine all four result sets into one having one row. How is it possible? I will write the queries for you. 1st one: Select Top 1 column1, column2 from table 1 where column 1 = 'something' and

Sql Server2005 query problem

霸气de小男生 提交于 2019-12-12 04:08:29
问题 i have a table which contains the following fields Supervisorid Empid This is just like a referral program. A guy can refer 3 guys under him i.e, 3 is referring three guys namely 4 5 8 similarly 4 is referring 9 10 and 11 likewise 8 is referring 12, 13 it goes like this.. I want a query to get the total no of down line members under a guy say 3 回答1: You can make use of Recursive CTE. Something like this DECLARE @Table TABLE( Supervisorid INT, Empid INT ) INSERT INTO @Table SELECT 3, 4 INSERT

How to write a query using self join on a table with huge data?

久未见 提交于 2019-12-12 04:07:57
问题 With the following table structure: Table 1: Customers CustID(primary key) | CustName(indexed) ---------------------------------- C1 Cust1 C2 Cust2 . Cust3 . Cust. . Cust. C10000 Cust10000 Table 2: CustomFields FieldID (primary key) | ID (indexed) | FieldValue --------------------------------------------------------------------- 1 C1 Test 2 C2 Test 3 C3 Test 4 C4 Test . . Test . . Test few millions Z1 Test "ID" column is indexed. Trying to output the following; CustID | Field 1 | Field 2 |