[英]How do I find the maximum row count after returning the results of a SQL query?
I have this query:我有这个查询:
SELECT * FROM Files WHERE FolderPath LIKE '%.SLDDRW' OR FolderPath LIKE '%.PDF'
And it's returning 82,614 rows (I know this because SSMS tells me it in the bottom corner, but I don't know how to turn that into a variable), and what I ultimately want to do is compare the file name from .foo
against .bar
and if the PDF has a string in it that says "REV A" or "REV B" I want to then update another table with a matching file ID as to what the revision is.它返回 82,614 行(我知道这一点是因为 SSMS 在底角告诉我,但我不知道如何将其转换为变量),我最终想要做的是将.foo
中的文件名与.bar
如果 PDF 中有一个字符串,上面写着“REV A”或“REV B”,我想用匹配的文件 ID 更新另一个表,以了解修订是什么。
An example of this would be:这方面的一个例子是:
If it's finding UniqueFileName1.SLDDRW
, and finding UniqueFileName1 REV A.PDF
in the same folder, I then want to update another table updating the REV value with whatever it finds there.如果它在同一个文件夹中找到UniqueFileName1.SLDDRW
并找到UniqueFileName1 REV A.PDF
,那么我想用它在那里找到的任何东西更新另一个表来更新 REV 值。
I'm new to SQL, so I'm not exactly sure how to pull data from the results of a query, but my game plan is to do a While
loop to do the comparison and update, but I need the maximum returned results from the first query to make sure the while loop terminates.我是 SQL 的新手,所以我不确定如何从查询结果中提取数据,但我的游戏计划是做一个While
循环来进行比较和更新,但我需要从确保 while 循环终止的第一个查询。 Right?正确的?
Ah, this is the solution: DECLARE @MaxRowCount INTEGER = @@RowCount
啊,这是解决方案: DECLARE @MaxRowCount INTEGER = @@RowCount
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.