如何创建输入的SQL Server作业 [英] How to create sql server jobs taking input

查看:92
本文介绍了如何创建输入的SQL Server作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我需要编写一个sql服务器作业,该作业需要两个输入并将值插入表中.这是使用系统的用户的用户名以及当天使用该系统的时间.我在工作中写了 step 来从表中获取用户名,这很好.但是问题是要获得所用的时间.我想在任务运行时动态地生成它,并且该值在任何表中都不可用,因为我在c#中编写了代码以获取所用的时间.无论如何,如果我们可以编写包含参数的作业,则可以将其存储在临时表中.

我已经搜索过此文件,但未找到任何结果.您能建议我如何编写一个具有输入参数的作业吗?

在此先感谢,
Naresh.

Hi there,

I need to write a sql server job which takes two inputs and inserts values into a table.That is the username of the user who is using the system and the time he used it for that day. I wrote a step in the job to get username from a table and is fine. But the problem is to get the used time. I want to generate it dynamicaly when the task runs and this value is not available in any table as I wrote the code in c# to get the used time.Anyway I may store it in a temp table if we can write a job taking parameters.

I''ve searched for this but not found any result.Can you people suggest me how to write a job that takes input parameters.

Thanks in Advance,
Naresh.

推荐答案

我为您提供了两个选择:
1.如果可以在表中使用已用时间",则可以创建一个存储过程,该存储过程采用当前用户的参数,并从临时表中读取与之对应的时间,并将其写入最终表中.在工作中,您只需执行存储的过程即可.

2.它更复杂,但是也许您可以将C#代码转换为标量CLR函数,但这会花费更多时间
I see two options for you:
1. if you can have the "time used" in a table you can create a stored procedure that takes a parameter the curent user and reads coresponding time from temp table and write it in final table. In job you just execute the strored procedure.

2. it is more complicated but maybe you can transform your C# code to a scalar CLR function, but this is much more time consuming


这篇关于如何创建输入的SQL Server作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆