如何在C#中构造如下语句(一定要带go,而且我不想分成多条语句):
create view V_Table1 as select * from Table1
go
insert into Table2(Name,Re) valus('AAA',null)
go我试了char(10)+char(13),空格,System.Environment.NewLine等方法,都不行,监视字符串的值,即使是得出这样的sql语句,直接在数据库中可以执行,但是在程序中报语法错误
create view V_Table1 as select * from Table1
go
insert into Table2(Name,Re) valus('AAA',null)
go我试了char(10)+char(13),空格,System.Environment.NewLine等方法,都不行,监视字符串的值,即使是得出这样的sql语句,直接在数据库中可以执行,但是在程序中报语法错误
解决方案 »
- 因为方法“get_Worker”没有实现(没有 RVA)。
- 如何将对象转化为二进制字节流?
- listbox 问题
- 急!急!关于用Session实现购物车的问题!
- C#程序連接db2數據庫驅動問題。。在數據庫版有高分求救。。。
- 为什么为什么?为什么会出现两张一样的表?
- 关于数据库操作的问题,帮帮忙!
- 用web服务做的winForm项目,从win2000升级到win2003怎么不能调用web服务
- winform程序中,在onload里添加线程的问题
- StructLayout类是干什么用的,它有什么用,什么时候用它呀?????????????
- winform绘制旋转字体的问题
- C#如何实现发送带表格数据的邮件
string sql = "create view V_Table1 as select * from Table1\r\ngo\r\ninsert into Table2(Name,Re) valus('AAA',null)\r\ngo\r\n";
也就是说去掉go之后的复合sql语句就是被sql server作为一个执行单元处理了?
也就是说如果要达使用go的效果的话,就要在程序中分步执行了?
如果在程序中用分号";"分割多条sql语句,如:
string strSql= create view V_Table1 as select * from Table1;insert into Table2(Name,Re) value('AAA',null)
";在sql server语法解析的过程中,会把解析为两个执行单元吗?如下
create view V_Table1 as select * from Table1
go
insert into Table2(Name,Re) valus('AAA',null)
go
---------------------------------------------
还是解析为一下等价语句?
create view V_Table1 as select * from Table1
insert into Table2(Name,Re) valus('AAA',null)
go
insert into Table2(Name,Re) valus('AAA',null);
我认为是:
create view V_Table1 as select * from Table1
insert into Table2(Name,Re) valus('AAA',null)因为这是在同一个批次中。
create view V_Table1 as select * from Table1
go
insert into Table2(Name,Re) valus('AAA',null)
go
---------------------------------------------
还是解析为一下等价语句?
create view V_Table1 as select * from Table1
insert into Table2(Name,Re) valus('AAA',null)
go
语法
GO
注释
GO 不是 Transact-SQL 语句;而是可为 osql 和 isql 实用工具及 SQL Server 查询分析器识别的命令。还有 create view V_Table1 as select * from Table1;和
insert into Table2(Name,Re) valus('AAA',null);一起执行是不可能的,create view 必须是批处理仅有语句
declare @x int;
set @x = 1;
select @x;但如果用了GO即使在SSMS中也会报错,说明不在一个批次中了:
declare @x int;
go
set @x = 1;
go
select @x;
go
insert into Table1(Name,Re) valus('AAA',null);
insert into Table2(Name,Re) valus('BBB',null)sql server会把上面的sql字符串分两次执行还是一次执行?
后insert into Table2(Name,Re) valus('BBB',null)
在一个批处理
是可以,我知道。重点在下面:
insert into Table1(Name,Re) valus('AAA',null);
insert into Table2(Name,Re) valus('BBB',null)sql server会把上面的sql字符串分两次执行还是一次执行?