???SQL Server?????????
???????????? ???????[ 2016/7/1 11:04:05 ] ????????????? SQL Server
?????????????????????4?????????些?????DBA????????????????CPU??煤??????SQL???????????????????????????????????
?????????泻??????????????????????????????????????????????????
???????????1.????????sql???????????????
????????????????????SQL??????????????????????????????????????????????貌??????貌????????????榉�????????????????????????SQL?????????貌???????????????????榉�????????SQL??????OK
???????????2.????????????????????????????????????????
????????????????????????????????????????????写??????????????????眉????????????写????榉�??????????????????????????????sql??????????SqlParameter????????SqlDbType??size????????????????????写?????泻???????????????????????????????????泄????????泄????胁??????????????????????????????????????????????????????????????????????????????????????????MSDN????????未??size?????????????Size?????dbType??????????????小??????????????????????小?????SqlDbType??????????????????????????????????????????????????绱�??????????"username"????size??8??"username1"????size??9????????????size?????????????????????????????size?????????????????????屑???????????????????????sql??????????????渭???屑????????????????????
???????????????????
????????????????
????DBCC FREEPROCCACHE
???????username?????????????????????????
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from Users where UserName=@UserName";
//??? username???????????????
//???????(@UserName varchar(8))select * from Users where UserName=@UserName
comm.Parameters.Add(new SqlParameter("@UserName"?? SqlDbType.VarChar) { Value = "username" });
comm.ExecuteNonQuery();
}
???????username1?????????????????????????
????????using (SqlConnection conn = new SqlConnection(connectionString))
????????{
????????conn.Open();
????????SqlCommand comm = new SqlCommand();
????????comm.Connection = conn;
????????comm.CommandText = "select * from Users where UserName=@UserName";
????????//??? username1???????????????
????????//???????(@UserName varchar(9))select * from Users where UserName=@UserName
????????comm.Parameters.Add(new SqlParameter("@UserName"?? SqlDbType.VarChar) { Value = "username1" });
????????comm.ExecuteNonQuery();
????????}
???????username??????????????50???????????
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from Users where UserName=@UserName";
//??? username??????????????50
//???????(@UserName varchar(50))select * from Users where UserName=@UserName
comm.Parameters.Add(new SqlParameter("@UserName"?? SqlDbType.VarChar??50) { Value = "username" });
comm.ExecuteNonQuery();
}
???username1??????????????50???????????
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from Users where UserName=@UserName";
//??? username1??????????????50
//???????(@UserName varchar(50))select * from Users where UserName=@UserName
comm.Parameters.Add(new SqlParameter("@UserName"?? SqlDbType.VarChar??50) { Value = "username1" });
comm.ExecuteNonQuery();
}
??????

???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11