1:查询分析器中直接运行
2:命令行下运行(先存为脚本文件)
isql -S 服务器名 -U sa -P 密码 -i "c:\aa.sql"
osql -U sa -P -S DB-Server -d SPVSDB -o err.txt -i c:\aa.sql -b
3:前台开发工具中用ADO执行
2:命令行下运行(先存为脚本文件)
isql -S 服务器名 -U sa -P 密码 -i "c:\aa.sql"
osql -U sa -P -S DB-Server -d SPVSDB -o err.txt -i c:\aa.sql -b
3:前台开发工具中用ADO执行
解决方案 »
- 关于VC ADO 连接本地SQL2005(迷茫了一周了)
- 导出数据到excel
- 在sql2005中,如何新建一个登录名, 只能连接 我建的数据库 mydb
- SQL 中不用分离数据库导出*.mdf和*.ldf文件
- 如何在VC中同ntext类型数据交换
- 一个排序的问题
- SQL SERVER 2000有用户数限制吗?!如何知道我的SQL SERVER 2000 最多支持多少用户????
- 求救 四个表查询的新问题
- 请教一个简单的问题:在SQL中想导出一个表的数据,但其中重复的数据不想导出,应如何做?
- 求把dbf导入SQL的方法,要具体的步骤,要是只会说个点导入就行了,那就请不用进来看了。给帮我搞定的100分。只给一个人。
- 如何对union后的结果排序呢?
- 请高手进来,跨服务器数据库的数据读取问题
就这样放在查询分析器都可以运行了
good luckSteps To Reproduce Behavior
In the SQL Server 7.0 Query Analyzer select the test database Pubs.
Create the following stored procedure. This stored procedure returns a recordset and an out parameter count.if exists (select * from sysobjects where id = object_id(N'[dbo].[GetJobs]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop proc GetJobs
go
create proc GetJobs @id as int, @count as int [out] as
begin
Select @count = Count(*) from jobs where job_id >@id
Select * from jobs where job_id >@id
end
go
Use VC App Wizard to create a new console application and modify the code as follows:#include "stdafx.h"
#include "stdio.h"
#import "C:\PROGRA~1\COMMON~1\System\ado\msado15.dll" no_namespace rename ("EOF", "EOF2") struct InitOle {
InitOle() { ::CoInitialize(NULL); }
~InitOle() { ::CoUninitialize(); }
} _init_InitOle_; int main(int argc, char* argv[])
{
_variant_t varErr((long)0, VT_ERROR);
_CommandPtr comm(__uuidof(Command));
_ConnectionPtr conn(__uuidof(Connection)); _bstr_t connstr="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=pubs;Data Source=(local)";
conn->Open(connstr, "", "", adConnectUnspecified);
comm->ActiveConnection=conn;
comm->CommandText="GetJobs";
comm->CommandType = adCmdStoredProc ;
comm->Parameters->Refresh();
_variant_t recs; comm->Parameters->Item[_variant_t((short)1)]->Value= _variant_t((long)5);
_RecordsetPtr rs = comm->Execute(&recs, &vtMissing,adCmdStoredProc); _variant_t recordcount= comm->Parameters->Item[_variant_t((short)2)]->Value; printf("recordcount = %li\n", (long)recordcount);
return 0;
}
Change the Datasource, User ID and password in the connection string above.
The recordcount variant that the above code returns is of type VT_NULL rather than the number of records that the stored procedure returns.