???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