sqlserver写程序,sqlserver写sql语句-成都快上网建站

sqlserver写程序,sqlserver写sql语句

C#如何编写一段程序,能控制SqlServer数据库服务重启?

public string RunDosCommand(string command)

成都创新互联是一家网站设计公司,集创意、互联网应用、软件技术为一体的创意网站建设服务商,主营产品:成都响应式网站建设公司成都品牌网站建设营销型网站建设。我们专注企业品牌在网站中的整体树立,网络互动的体验,以及在手机等移动端的优质呈现。成都网站建设、网站制作、移动互联产品、网络运营、VI设计、云产品.运维为核心业务。为用户提供一站式解决方案,我们深知市场的竞争激烈,认真对待每位客户,为客户提供赏析悦目的作品,网站的价值服务。

{

Process process = new Process();

process.StartInfo.FileName = "cmd.exe";

process.StartInfo.UseShellExecute = false;

process.StartInfo.RedirectStandardInput = true;

process.StartInfo.RedirectStandardOutput = true;

process.StartInfo.RedirectStandardError = true;

process.StartInfo.CreateNoWindow = true;

process.Start();

process.StandardInput.WriteLine(command);

process.StandardInput.WriteLine("exit");

return process.StandardOutput.ReadToEnd();

}

command 参数可以输入如

net start mssqlserver

net stop mssqlserver

编写一个SQLSERVER 存储过程

代码是最好的文字,不多说,请看我的代码,并给分,呵呵。

--step1. 建表

if exists(select * from sysobjects where id=object_id('student') and objectproperty(id,'IsTable')=1)

drop table student

go

create table student

(

id int identity(100,10) not null

,sname varchar(10) not null

,sno varchar(30) not null

)

go

--step2.建存储过程

if exists(select * from sysobjects where id=object_id('proc_demo') and objectproperty(id,'IsProcedure')=1)

drop procedure proc_demo

go

create procedure proc_demo

@o_maxid int output

as

set nocount on

--如果希望大小写敏感,使用第一句,因为SQL Server默认是大小写不敏感的

--update student set sno='cay_'+sno where ascii(substring(sname,1,1))=87 and ascii(substring(sname,2,1))=65 and sno not like 'cay_%'

update student set sno='cay_'+sno where sname like 'WA%' and sno not like 'cay_%'

print convert(varchar(10),@@rowcount)+'条记录符合条件并被处理'

select @o_maxid=max(id) from student where id=100

if(@o_maxid is null) print '没有找到符合条件的最大记录'

set nocount off

go

--测试数据1

truncate table student

set identity_insert student on

insert into student(id,sname,sno)values(1,'WA1','1');

insert into student(id,sname,sno)values(2,'wa2','2');

insert into student(id,sname,sno)values(3,'3','3');

set identity_insert student off

go

--测试数据2

truncate table student

insert into student(sname,sno)values('WA1','1');

insert into student(sname,sno)values('wa2','2');

insert into student(sname,sno)values('3','3');

go

--测试过程

declare @maxid int

exec proc_demo @maxid out

print '最大id是'+convert(varchar(10),@maxid)

go

帮我写个分页的程序?(c# Sqlserver)

%@ Import Namespace="System.Data"%

br%@ Import Namespace="System.Data.SqlClient" %

brscript language="C#" runat="server"

brvoid Page_load()

br{

brif (!IsPostBack)

br{

brstring strConnection = "server=127.0.0.1;";

brstrConnection += "database=ztx;uid=sa;password=wxj;";

brSqlConnection sqlConnection1 = new SqlConnection(strConnection);

brstring strSql = "select top 20 i_id,i_caption,i_count,substring(i_content,1,20) as i_content from content";

brSqlDataAdapter sqlAdapter = new SqlDataAdapter(strSql, sqlConnection1);

brDataSet objDataSet = new DataSet();

brsqlAdapter.Fill(objDataSet);

brViewState["objDataSet"]=objDataSet

brbind();

br}

br}

br

brprotected void abc(object source, DataGridPageChangedEventArgs e)

br{

br

brzhangtianxing.CurrentPageIndex = e.NewPageIndex;

brbind();

br}

br

br protected void button1(object sender, EventArgs e)

br {

br zhangtianxing.CurrentPageIndex += 1;

br bind();

br }

br private void bind()

br {

br DataSet objDataSet = (DataSet)ViewState["objDataSet"];

br zhangtianxing.DataSource = objDataSet;

br zhangtianxing.DataBind();

br }

br/script

brhtml

brhead

brtitle中国新闻搜索中心/title

br/head

brbody

br

brform id="Form1" runat="server"

brtabletrtdasp:datagrid ID="zhangtianxing" runat="server" AllowPaging="True" PageSize="3" / /td/trTrtd

brasp:LinkButton OnClick="button1" ID="LinkButton1" runat="server"LinkButton/asp:LinkButton /td/tr/table

br/form

br/body

br/html

用 delphi写个程序把SQLserver一个表中的数据逐行写入txt文件

方法比较多,就说两种先

var i,j:Integer;

s:string;

myfile:textfile;

begin

with query1 do

begin

close;

sql.clear;

sql.add('select * from sb_fcs');

open;

end;

AssignFile(myfile,'d:\2.txt');

Rewrite(myfile);

try

for i:=0 to query1.recordcount-1 do

begin

for j:=0 to query1.FieldCount-1 do

BEGIN

s:=query1.fields[j].name+':'+query1.fields[i].asstring+',';

writeln(myfile,s);//myfile 为要写的txt文件

end;

query1.next;

end;

finally CloseFile(myfile);

END;

end;

方法二:

s1:string;

s:tstringlist;

with query1 do

begin

s1:='';

for i:=0 to fieldcount-1 do s1:=s1+fields[i].asstring+' ';

s.add(s1);

循环读入

next;

end;

s.savetofile('c:\a.txt');


文章名称:sqlserver写程序,sqlserver写sql语句
URL网址:http://kswjz.com/article/hdijch.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流