sql-server-2005

SQL HAVING SUM GROUP BY

别来无恙 提交于 2020-01-04 09:15:30
问题 Using SQL Server 2005. I am building an inventory/purchasing program and I’m at the point where I need the user to “check out” equipment. When he selects a product, I need to query which stock locations have the available Qty, and tell the user which location to walk to/ retrieve product. Here is a query for a particular [StockLocation_Products].ProductID, with a particular assigned [ProductUsages].ProductUsageID. SELECT PROD.ProductID, PROD.ProductName, SL.Room, SL.StockSpace, SLPPU.ResvQty,

Do stored procedures have the ability to delete a file from the OS?

旧时模样 提交于 2020-01-04 09:15:08
问题 Out of curiosity, does a stored procedures have the ability to delete a file from the OS? If not I will have to make a windows Batch file that deletes the file and then runs the stored procedure using OSQL. 回答1: Technically, with the correct permissions, you could execute xp_cmdshell to issue commands to the OS (or call a batch file, whatever), but it's probably not a good idea. If you do use that method, be very strict about permissions. Edited for clarity. 回答2: Try this Option 1 delete a

Query on Sql Joins

99封情书 提交于 2020-01-04 09:09:13
问题 I have three tables. tblLink: (LinkId, LinkName, GroupId, ,SubGroupId) GroupId and SubGroupId are foreign key in tblGroup and tblSubGroup tblGroup: (GroupId, GroupName) tblSubGroup: (SubGroupId, SubGroupName) in tblLink SubGroupId is allowed Null but GroupId is Mandatory. I want to fetch LinkName, GroupName, SubGroupName for every LinkId in tblLink I have written a query SELECT L.LinkName, G.GroupName, SG.SubGroupName FROM tblLink L Left Join tblSubGroup SG ON (L.SubGroupId=SG.SubGroupId)

Query on Sql Joins

ⅰ亾dé卋堺 提交于 2020-01-04 09:09:12
问题 I have three tables. tblLink: (LinkId, LinkName, GroupId, ,SubGroupId) GroupId and SubGroupId are foreign key in tblGroup and tblSubGroup tblGroup: (GroupId, GroupName) tblSubGroup: (SubGroupId, SubGroupName) in tblLink SubGroupId is allowed Null but GroupId is Mandatory. I want to fetch LinkName, GroupName, SubGroupName for every LinkId in tblLink I have written a query SELECT L.LinkName, G.GroupName, SG.SubGroupName FROM tblLink L Left Join tblSubGroup SG ON (L.SubGroupId=SG.SubGroupId)

SQL Selecting MIN value from row data, not column data

孤街醉人 提交于 2020-01-04 09:08:14
问题 Using SQL 2005, is there a way to select the minimum value between 5 columns within one single row of data? So, if I have a row of data like this: id num1 num2 num3 num4 num5 1 22 51 4 99 34 Then, how can I get the lowest value using SQL? 回答1: You can create a UDF. create function GetMin(@N1 int, @N2 int, @N3 int, @N4 int, @N5 int) returns table as return (select min(N) as Value from (select @N1 union all select @N2 union all select @N3 union all select @N4 union all select @N5) as T(N)) And

Updating row in table based on sub query on same table

旧街凉风 提交于 2020-01-04 06:58:31
问题 I have a column in 'tableA' which i would like to update with the result from the following query. Basically the 5th date column will be the maximum date from the other 4 columns on the same row. select Case when date1 >= date2 and date1 >= date3 and date1 >=date4 then date1 when date2 >= date1 and date2 >= date3 and date2 >=date4 then date2 when date3 >= date1 and date3 >= date2 and date3 >=date4 then date3 when date4 >= date1 and date4 >= date2 and date4 >=date3 then date4 End as Date5 from

Updating row in table based on sub query on same table

半腔热情 提交于 2020-01-04 06:57:09
问题 I have a column in 'tableA' which i would like to update with the result from the following query. Basically the 5th date column will be the maximum date from the other 4 columns on the same row. select Case when date1 >= date2 and date1 >= date3 and date1 >=date4 then date1 when date2 >= date1 and date2 >= date3 and date2 >=date4 then date2 when date3 >= date1 and date3 >= date2 and date3 >=date4 then date3 when date4 >= date1 and date4 >= date2 and date4 >=date3 then date4 End as Date5 from

Table variable row limitation?

旧街凉风 提交于 2020-01-04 06:18:09
问题 I have in my application a user defined function which takes a comma separated list as an argument. It splits the items and plugs them in to a table variable and returns the result. This function works well, except that when the items in the comma separated list exceed 1000, it ignores the remainder. That is to say, if I plug in 1239, the first 1000 rows will be returned and the remaining 239 are entirely ignored. There are no errors when this occurs. I can't help but feel that this is due to

What storage location, SQL Server or file system, would result in better performance in saving tiff images?

走远了吗. 提交于 2020-01-04 06:09:47
问题 Our system needs to store tiff images of ~3k in size. We receive ~300 images at a given time and need to quickly process them. Once ~100,000 images are received, the images are transferred off our system to another archival system or purged. I am looking for best performance in regards to the initial save of the image files. The task of transferring the images for archival is less performance critical. What storage location, SQL Server or file system, would result in better performance in

What storage location, SQL Server or file system, would result in better performance in saving tiff images?

时光怂恿深爱的人放手 提交于 2020-01-04 06:09:19
问题 Our system needs to store tiff images of ~3k in size. We receive ~300 images at a given time and need to quickly process them. Once ~100,000 images are received, the images are transferred off our system to another archival system or purged. I am looking for best performance in regards to the initial save of the image files. The task of transferring the images for archival is less performance critical. What storage location, SQL Server or file system, would result in better performance in