此存储过程不返回小数格式为00.00的工资
ALTER PROCEDURE taxable_varsalary
@emp_code bigint,
@co_id bigint
AS
declare @t_varsalary decimal(8,2)
set @t_varsalary = (select sum(tran_value) from emp_ded_ben_trans where emp_code=@emp_code and co_id=@co_id and period_flg=2 and tax_flg=0)
RETURN @t_varsalary
Run Code Online (Sandbox Code Playgroud) 如何在SQL Server 2005中获取数据库的物理数据库和日志文件位置(文件系统路径)?
我用它来获取mdf文件:{SELECT [Name],FileName FROM sysdatabases}但是还需要获取日志文件...
干杯,康纳
我试图在后面的代码中执行asp.net中的存储过程.我试图传递的参数是包含值的strErrorMessage"The transport failed to connect to the server.; ".
执行查询时的错误消息是: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 ("@errMessage"): Data type 0xE7 has an invalid data length or metadata length.
使用代码更新
try
{
...
...
...
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email was not sent - " + ex.Message + "');", true);
string strMessage = ex.Message;
string strStackTrace = ex.StackTrace;
strMessage = strMessage.Replace("\r\n", "; ");
strMessage = …Run Code Online (Sandbox Code Playgroud) 我需要一些当然不起作用的东西.
insert into Table1
(
Id,
Value
)
select Id, value from
(
exec MySPReturning10Columns
)
Run Code Online (Sandbox Code Playgroud)
我想从返回的结果集中填充Table1 MySPReturning10Columns.这里SP返回10列,表只有2列.
只要SP中的表和结果集具有相同的列数,以下方式就可以工作,但在我的情况下它们不相同.
INSERT INTO TableWith2Columns
EXEC usp_MySPReturning2Columns;
Run Code Online (Sandbox Code Playgroud)
另外,我想避免添加"." 作为链接服务器,无论如何只是为了使openquery和openrowset工作.
有没有办法不在临时表中定义表结构(所有具有数据类型和长度的列)?像CTE这样的东西.
如何使用SQL Server 2005中的元数据获取存储过程的输入参数列表?我想对它做一个SELECt,然后迭代变量名.
我有一个在MS SQL Server 2005上运行的数据库和一个ASP.NET 3.5 Web应用程序.
该数据库包含一个产品目录,我用它来将"页面"提供给在Web应用程序中运行的CMS.创建页面后,应用程序会缓存它们,因此我需要通知应用程序此更改,以便重新创建页面对象.
CMS使用它自己的缓存,因此不能使用SqlCacheDependency来执行此任务.
当我启动应用程序时,我确实让订阅者出现在结果中
select * from sys.dm_qn_subscriptions
Run Code Online (Sandbox Code Playgroud)
但是,只要我向表中添加一些数据,订阅者就会消失,并且OnChanged事件永远不会触发.
在我的启动代码中,我有以下内容
// Ensure the database is setup for notifications
SqlCacheDependencyAdmin.EnableNotifications(DataHelper.ConnectionString);
SqlCacheDependencyAdmin.EnableTableForNotifications(DataHelper.ConnectionString, "Category");
SqlCacheDependencyAdmin.EnableTableForNotifications(DataHelper.ConnectionString, "Product");
if (!SqlDependency.Start(DataHelper.ConnectionString, SqlDependencyQueueName))
throw new Exception("Something went wrong");
string queueOptions = string.Format("service = {0}", SqlDependencyQueueName);
using (var connection = new SqlConnection(DataHelper.ConnectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand(@"SELECT [CategoryID],[Name]
FROM [dbo].[Category]", connection))
{
// Create a dependency and associate it with the SqlCommand.
dependency = new SqlDependency(command, queueOptions, 0);
// Subscribe …Run Code Online (Sandbox Code Playgroud) 我有一个@StartDate和@EndDate.
我需要@StartDate作为查询运行的那一天(这将始终是本月的第一天)和@EndDate在月末是exaclty,无论月份是30天还是31天等.
我不确定这里是否可以提出这个问题或者是serverfault.我在想...除了从备份中恢复之外,有没有办法快速撤消SQL Server 2005 Tuning Advsor所做的更改?
假设我在表中有一个数据类型为XML的列.我有一个特定的值,我想要在XML中的唯一(不重复)的xml标记中查询.我该怎么做呢?
就像是:
select * from MyTable
where XMLColumn.TagImLookingAt.Value = @QueryValue
Run Code Online (Sandbox Code Playgroud) 我看到我的实例和我老板的SSMS实例之间存在一个有趣的行为差异.当他对表使用任务 - >生成脚本...时,它会围绕该表的触发器设置保护(如果存在...)但是当我使用相同的选项执行相同的操作时,SSMS不会将保护放在如果我运行它不止一次生成的脚本,我会收到错误.知道我怎么能让SSMS为我生成触发器的守卫吗?