我在将我在MS Visual Studio 2008/MS SQL Server 2008中的一台服务器上创建的SSIS包移动到具有MS SQL Server 2005的服务器时遇到问题.我收到以下错误并感谢您的建议:
在SQL Server中存储或修改包需要SSIS运行时和数据库是相同的版本.不支持在早期版本中存储包.
地址文本框中有单引号和双引号.如何插入数据库.我正在使用SQL2005.我的代码如下......
str = "exec sp_cust_reg '" + customer.Cust_Id + "','" + customer.Cust_Name + "','" + customer.Gender + "','" + customer.Acc_no + "','" + customer.Address + "','" + customer.Pin_no + "','" + customer.Phone_no + "','" + customer.Mobile_no + "','" + customer.Email + "','" + customer.Authorise + "'";
Run Code Online (Sandbox Code Playgroud)
地址是jo"hn's house
它的Text Visualizer如下......
exec sp_cust_reg 'C7','George Joseph','Male','0001-212123','jo"hn's house','515151','04862787896','8888888888','johnyqw@gmail.com','N'
Run Code Online (Sandbox Code Playgroud)
我用了
string sql = str.Replace("\'", " ");.
Run Code Online (Sandbox Code Playgroud)
然后我明白了
exec sp_cust_reg C7 , George Joseph , Male , 0001-212123 , jo"hn s house , 515151 , …Run Code Online (Sandbox Code Playgroud) 我试图插入到SQL数据库但是我一直收到错误

以下是提到的查询:
str2 = "Insert into [Snaps](Loc_city,Loc_state,Loc_country,Edu_Hist1,Work_Hist1) values (Loc_city= ' " + soap.data[i1].current_location.city.ToString() + "', Loc_state='" + soap.data[i1].current_location.state.ToString() + "', Loc_country='" + soap.data[i1].current_location.country.ToString() + "',Edu_Hist1='" + soap.data[i1].education_history[0].name.ToString() + "', Work_Hist1 ='" + soap.data[i1].education_history[0].school_type.ToString()+"')";
cmd = new SqlCommand(str2,con);
cmd.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)
请帮忙
insert into patient_record(patient_no, patient_name, datetime_of_birth,
GP_unique_no, GP_name, GP_address,complaint,
treatment, doctor, datetime_treatment_started,
datetime_treatment_ended)
values(13, 'Sophie', '1955-05-13', 'G202',
**select name_of_doctor from gp_doctor where unique_no=G202**,
'Yorkshire', 'Broken right arm', 'Plaster Arm', 'Peter Parker',
'2012-01-25','2012-01-29')
Run Code Online (Sandbox Code Playgroud)
我不知道如何添加G202.任何的想法?
可能重复:
计算SqlServer中的运行总计
我需要在ms-sql server中获取一列的累积(运行)总数.即如果存在名为"Marks"的列,则对应于每行累积和将是当前行和前一行的总和.我们可以在不使用连接的情况下获得结果吗?因为我的查询非常大.
我已经包含了一个示例表和数据:
CREATE TABLE "SCORE_CHART"
(
"STUDENT_NAME" NVARCHAR(20),
"MARKS" INT
)
INSERT INTO SCORE_CHART (STUDENT_NAME, MARKS) VALUES ('STUD1', 95);
INSERT INTO SCORE_CHART (STUDENT_NAME, MARKS) VALUES ('STUD2', 90);
INSERT INTO SCORE_CHART (STUDENT_NAME, MARKS) VALUES ('STUD3', 98);
SELECT STUDENT_NAME, MARKS FROM SCORE_CHART;
Run Code Online (Sandbox Code Playgroud)
预期结果:

在oracle中,它很容易编写如下:
SELECT
STUDENT_NAME,
MARKS,
SUM(MARKS) OVER (ORDER BY STUDENT_NAME) CUM_SUM
FROM SCORE_CHART
ORDER BY STUDENT_NAME;
Run Code Online (Sandbox Code Playgroud)
提前致谢.
String dmlString="INSERT INTO table VALUES('Rxyz');
SqlCommand comObj = new SqlCommand(dmlString, conObj);
comObj.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)
表 - > Rxyz
如何验证它,如Rxyz(区分大小写)
SELECT ProductNumber, Category =
CASE ProductLine
WHEN 'R' or 'r' THEN 'Road'
WHEN 'M' or 'm' THEN 'Mountain'
WHEN 'T' or 't' THEN 'Touring'
WHEN 'S' or 's' THEN 'Other sale items'
ELSE 'Not for sale'
Run Code Online (Sandbox Code Playgroud)
我的基本要求是对CASE使用'OR'(如果可能的话),请建议我是否做错了.
我有这张桌子
customer sunday monday tuesday wedesneday thursday friday saturday
1 0 0 1 1 1 0 0
2 0 1 0 0 0 0 1
3 0 0 1 0 1 0 1
4 0 0 1 1 0 1 0
5 0 1 0 0 1 1 1
6 0 0 1 0 1 1 0
7 0 1 0 1 1 0 1
8 0 0 0 0 1 1 0
9 0 1 1 1 0 0 …Run Code Online (Sandbox Code Playgroud) 我有表tbMeasurement和tbPatientMeasurement.
tbMeasurement
MeasurementIDP
MeasurementName
Run Code Online (Sandbox Code Playgroud)
tbPatientMeasurement
PatientMeasurementIDP
MeasurementIDF
MeasurementValue
Taken (Datetime)
Run Code Online (Sandbox Code Playgroud)
执行以下查询时:
SELECT DISTINCT dbo.tbMeasurement.MeasurementName
, dbo.tbPatientMeasurement.MeasurementValue
, dbo.tbPatientMeasurement.Taken
FROM dbo.tbMeasurement
INNER JOIN dbo.tbPatientMeasurement
ON dbo.tbMeasurement.MeasurementIDP = dbo.tbPatientMeasurement.MeasurementIDF
Run Code Online (Sandbox Code Playgroud)
这将返回其中一个MeasurementName的双重条目.我也想要MeasurementName,MeasurementValue by max Taken(datetime).
我正在尝试创建一个SQL语句,将可变数量的行(最多5个)转换为单行.一小部分数据如下所示:
+--------------+--------+-------+-------+
| ID | ItemID | Style | Qty |
+--------------+--------+-------+-------+
| 00001-5A-2XL | F911-5 | F911 | 1.566 |
| 00001-5A-2XL | 233-5 | 233 | 0.236 |
| 00001-5A-3XL | F911-5 | F911 | 1.697 |
| 00001-5A-3XL | 233-5 | 233 | 0.237 |
| 00001-5A-4XL | F911-5 | F911 | 1.833 |
| 00001-5A-4XL | 233-5 | 233 | 0.239 |
| 00001-5A-L | F911-5 | F911 | 1.307 |
| 00001-5A-L | 233-5 | …Run Code Online (Sandbox Code Playgroud)