首页 \ 问答 \ C#和SQL Server 2005(C# and SQL Server 2005)

C#和SQL Server 2005(C# and SQL Server 2005)

我有4张表,我从中获取记录。 前三个表需要内部连接和公共行,但是第四个表我需要左外连接,因为我必须保留前三个表中已经获取的行。

现在,问题是我希望左连接第四个表但它应该只选择具有date =当前日期的记录。 我在调用我的存储过程时从C#传递当前日期。 但问题是SQL Server正在提供空记录。

这是查询::

alter procedure
  (@currentdate varchar(50))
  select distinct 
      table1.name, table2.class,table3.stream 
  from 
      table1
  inner join 
      table 2 on table1.id = table2.id 
  inner join 
      table3 on table3.id=table2.id   
  left outer join 
      table 4 on table 4.id = table3.id and table4.date = @currentdate

我使用和左外连接因为我想要那样的记录,使用where子句过滤整个结果,只给我一条记录。

然后我也使用了存储过程中的两个日期,但没有正面响应。

从C#我正在使用

var date = datetime.now.toshortdate();
CallStoredProcedure(date)

请尽快帮助我。 谢谢


I have 4 tables from which I am fetching records. The first three tables required inner join with the common rows but with 4th table I need left outer join because I have to preserve the already fetched rows from first three tables.

Now, problem is that I want left join with fourth table but it should only pick the records having date = current date. I am passing current date from C# while calling my stored procedure. But the thing is SQL Server is giving null records.

Here is the query::

alter procedure
  (@currentdate varchar(50))
  select distinct 
      table1.name, table2.class,table3.stream 
  from 
      table1
  inner join 
      table 2 on table1.id = table2.id 
  inner join 
      table3 on table3.id=table2.id   
  left outer join 
      table 4 on table 4.id = table3.id and table4.date = @currentdate

I used and with left outer join because I want records in that way where as using where clause filters the whole result and just give me one record.

Then also I used casting with both the dates in stored procedure but no positive response.

From C# I'm using

var date = datetime.now.toshortdate();
CallStoredProcedure(date)

Please help me regarding this ASAP. Thank you


原文:https://stackoverflow.com/questions/17257888
更新时间:2022-03-08 12:03

最满意答案

我认为设计很好,因为每个线程都应该有它需要的变量的副本。

你说:

例如,我可以使用map.putIfAbsent()来使操作以原子方式执行

但是这不会让你的地图线程安全,因为有人可以调用其他的东西。


I think the design is good because each thread should have a copy of the variables it needs.

You said:

For instance, I can use map.putIfAbsent() to make the operation be performed atomically

but this does not make your map thread safe because someone could call something else on it.

相关问答

更多
  • 您不会看到使用单个变量重新排序的问题。 但是拿两个...... int foo = 0; boolean isFooSet = false; ... // thread 1 foo = 42; isFooSet = true; ... // thread 2 while (!isFooSet) {/*waste some time*/} // we wait until the flag is set in the other thread System.out.println(42/foo); //we ...
  • 下面是一个示例,其中所有值和更改将在每个会话中是唯一的。 请注意,我将old变量包装在reactiveValues() 。 我也改为observeEvent因为我认为它更适合你的情况。 请注意,更改sliderA会导致sliderB发生变化,因此sliderC也会更新。 如果您有任何疑问,请与我联系 rm(list = ls()) library(shiny) a_new <- 10 b_new <- 10 c_new <- 10 ui <- fluidPage( sidebarLayout( ...
  • 尽管写操作是异步的,但这里没有多线程: do_write()在一个线程中被调用。 当然,发送的缓冲区必须处于活动状态且不变,直到调用完成处理程序。 从任何线程调用post()和dispatch()都是安全的。 阅读io_service文档的 “线程安全”部分。 如果async_write正在进行中,并且您再次在同一个套接字上调用async_write ,则未定义数据的发送顺序。 换句话说,数据将被搞砸。 解决此问题的最简单方法是创建消息队列:每次async_write完成时,发出另一个async_write ...
  • 不,这不是问题。 在PHP中,全局变量对于特定请求是唯一的。 除非使用会话,否则无法更改或读取其他请求中的变量。 No, it's not an issue. In PHP, global variables are unique to the specific request. You cannot alter or read variables from another request, except by using sessions.
  • Re thread_concurrency: 不推荐使用此变量,并在MySQL 5.7中删除。 除非它们适用于Solaris 8或更早版本,否则无论何时看到它都应从MySQL配置文件中删除它。 所以,不要费心去改变它。 同时,我会说你的观察是“正常的”。 也就是说,你的450个连接正在进行非常快速的查询,因此当你看时,你恰好只能看到11个中间的东西。 您是否在应用中看到任何意外延迟? 我怀疑没有。 您是否比其他查询更频繁地看到某些特定查询? 是否显示Time超过,例如,“2”?如果是,请查看查询,再加上SH ...
  • 你的第二个视图控制器是错误的,所以它不知道变量toPass 。 尝试改变这一点: var secondVC = segue!.SecondViewController as ViewController; 为此: if let secondVC = segue.destination as? SecondViewController { secondVC.toPass = "email" } Your cast of the second view controller is wron ...
  • 如果要更改for-each循环内的变量值(并且可能也在同一循环中使用它),则应将并发设置为1以确保循环以顺序方式运行以避免竞争条件。 If you are changing the variable value inside the for-each loop (and potentially also consuming it in the same loop), you should set concurrency to 1 to ensure the loop runs in a sequential ...
  • 我认为设计很好,因为每个线程都应该有它需要的变量的副本。 你说: 例如,我可以使用map.putIfAbsent()来使操作以原子方式执行 但是这不会让你的地图线程安全,因为有人可以调用其他的东西。 I think the design is good because each thread should have a copy of the variables it needs. You said: For instance, I can use map.putIfAbsent() to make the ...
  • 处理此问题的最佳方法是捕获std::atomic的实例,该实例提供了一个线程安全计数器。 根据lambda的生命周期和周围范围,您可能希望通过引用或共享指针捕获。 举个例子: std::vector workers; auto counter = std::make_shared>(0); for (int i = 0; i < 5; i++) { workers.push_back(std::thread([counter]() ...
  • 对于通用线程安全队列,您可以使用ConcurrentLinkedQueue,或者如果要一次限制队列中的一个对象,则SynchronousQueue最终一次只有一个对象,但可以使用ArrayBlockingQueue预先计算下一个对象。 Java内存模型允许有效地缓存值,以及编译器重新排序指令,假设只有一个线程在运行时重新排序不会改变结果。 因此,生产者不能保证将vFlag视为真,因为它允许使用缓存的值。 因此,消费者线程将vflag视为true,并且生产者将其视为false。 将变量声明为volatile意 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)