The revision numbers (revno) are unique per itemcode.I would like to get only the rows with the highest revision per itemcode, but I also need the prodspecUID with is the index key and therefore unique.I have tried MAX() and TOP 1's in sub queries, but up until now without any result.
I have some code I build 2 weeks ago which I’ve been running daily but it’s suddenly stopped working with the following error.
“The table "tbl_Intraday_Tmp" has been created, but its maximum row size exceeds the allowed maximum of 8060 bytes. INSERT or UPDATE to this table will fail if the resulting row exceeds the size limit” When I google this there seems to be a related to tables with vast numbers of columns.
My table tbl_Intraday_tmp is relatively small. It has 7 columns. 1 of varchar(5), 3 of decimal(9,3) and 2 of decimal(18,0). The bit I’m puzzled with is it was working and stopped.
I don’t recall changing anything but I wouldn’t rule that out. I ‘ve inspected the source files and I don’t believe they have changed either.
SQL Server 2000 8.00.760 (SP3)I've been working on a test system and the following UDF worked fine.It runs in the "current" database, and references another database onthe same server called 127-SuperQuote.CREATE FUNCTION fnGetFormattedAddress(@WorkID int)RETURNS varchar(130)ASBEGINDECLARE@Address1 As varchar(50)@ReturnAddress As varchar(130)SELECT@Address1 = [127-SuperQuote].dbo.tblCompany.Address1FROM[Work] INNER JOIN[127-SuperQuote].dbo.tblCompany ON [Work].ClientID =[127-SuperQuote].dbo.tblCompany.CompanyIDWHERE[Work].WorkID = @WorkIDIF @Address1 IS NOT NULLSET @ReturnAddress = @ReturnAddress + @Address1 + CHAR(13)+ CHAR(10)RETURN @ReturnAddressENDSo now the system has gone live and it turns out that the live"SuperQuote" database is on a different server.I've linked the server and changed the function as below, but I get anerror both in QA and when checking Syntax in the UDF builder:The number name 'Zen.SuperQuote.dbo.tblCompany' contains more than themaximum number of prefixes. The maximum is 3.CREATE FUNCTION fnGetFormattedAddress(@WorkID int)RETURNS varchar(130)ASBEGINDECLARE@Address1 As varchar(50)@ReturnAddress As varchar(130)SELECT@Address1 = Zen.SuperQuote.dbo.tblCompany.Address1FROM[Work] INNER JOINZen.SuperQuote.dbo.tblCompany ON [Work].ClientID =Zen.SuperQuote.dbo.tblCompany.CompanyIDWHERE[Work].WorkID = @WorkIDIF @Address1 IS NOT NULLSET @ReturnAddress = @ReturnAddress + @Address1 + CHAR(13)+ CHAR(10)RETURN @ReturnAddressENDHow can I get round this? By the way, I've rather simplified thefunction to ease readability. Also, I haven't posted any DDL because Idon't think that's the problem!ThanksEdward
I use SQL Server 2005. I have approx. 50 tables in my database and 30 of them have a filed named "CompanyID". Example: create table A (ID int identity, NAME varchar(100), COMPANYID int)create table A (ID int identity, REF_ID int, FIELD1 varchar(100), FIELD2 varchar(100), COMPANYID int)
Also there are nearly 200 stored procedures that read data from these tables. Example: create procedure ABCasbegin /* some checks and expressions here ... */ select ... from A inner join B on (A.ID = B.REF_ID) where ... /* ... */end;
All my queries in the Stored procedure does not filter the tables by CompanyID, so they process the entire data.
However, now we have a requirement to separate the data for each company. That means that we have to put a filter by CompanyID to each of those 20 tables in each query where the tables appear.
Firstly, I put the CompanyID in the context so now its value is accessible through the context_info() function. Thus I do not need now to pass it as a parameter to the stored procedures.
However, I don't know what is the easiest and fastest way to filter the tables. Example:
I modified the above mentioned procedure in the following way: create procedure ABCasbegin /* some checks and expressions here ... */ -- gets the CompanyID from the context: DECLARE @CompanyID int; SELECT @CompanyID = CONVERT(float, CONVERT(varchar(128), context_info())) select ... from A inner join B on (A.ID = B.REF_ID) where ... and A.COMPANYID = @CompanyID and B.COMPANYID = @CompanyID /* ... */end;
Now I have the desired filter by CompanyID. However, modifying over 200 stored procedures is rather tedious work and I don't think that this is the best approach. Is there any functionality in SQL Server that can provide the possibility to put an automatic filter to the tables. For example: when I wrote "SELECT * FROM A", the actual statements to be executed would be "SELECT * FROM A WHERE CompanyID = CONVERT(float, CONVERT(varchar(128), context_info()))".
I was looking for something like "INSTEAD OF SELECT" triggers but I didn't manage to find any answer.
I would very grateful is someone suggests a solution for something like "global table filter" (that will help me make an easy refactoring)?
I have a table that has a group. In this group, I want to filter by 2 different expressions, concatenated with an OR. BUT I can't change the "And/Or" column value for the first entry because it is grayed out. The column will automatically change to an OR value if both my expression column fields are the same (which I dont want) but if I put any other value in to the expression field of the second row, the "And/Or" field of the first row automatically changes to an AND.
PLEASE! How do I get the And/Or field "ungrayed" so I can change it to what I want?
The 2 filters I and using check the UserID = to the user, and the other is checking a count to get the Top N 1. (So just showing the current user and the top producer)
hi, im trying to get the last row of a column by using this code cmd.CommandText = "SELECT max(orderID) as orderID from orders where memberNo = '" & Session.Item("memberNum") & "'"but it return me 1 instead which is the smallest value in my orderID column n located in the first rowthen i try to use this code but they say got syntax errorcmd.CommandText = "SELECT max(orderID) as orderID from orders where memberNo = '" & Session.Item("memberNum") & "'" ' order by orderID asc " ' and orderID = '" & Session("ordersID") & "'" can anyone tell me the right way to write the syntax?? thx in advance
Does anyone know the specific website that documents the maximum RAM SQL 7.0 Standard and Enterprise edition can handle within Windows 2000 Server and Windows 2000 Advanced server? All help appreciated!!
Our development team is doing some stuff in ASP. They are interested only in char and varchar data types. They clearly told us that they are not going with text and image data types.
Is it possible to make a row size behind 8060 bytes in a table without text and image data types?.
I have a table with 188376 rows and the data size = 3012 KB, index size = 5884 KB . LE threshold max is set to 2000 and LE threshol percent to 20% I have an index on that table and observed that it is not getting used. I would like to know whether sql optimizer uses the index based on the cost of the query plan or does the table scan once the LE thresholdlimit is reached overriding the optimized plan.
I'm using replication between two server, but I don't know the maximum record will be move from Database 1 on Server1 to Database2 on Server2 in per minute.please help me, thanks!
Without technical information and DB design, I wish to know the maximum entries in MS SQL in million. I guest for access are a limit of 2 million and a 2GB DB. How much for MS SQL in max. entries and how much in GB?
I have 4 columns and 3 rows. Columns are Name, Age, Gender and Weight. I have values entered for each column. I need to pick the highest value of weight if Name, Age, Gender are same and put that into new table. how can i do that?
Hi... I have written a stored procedure with number of inserts as the input variables which will input those many rows into my execution table... When i try to input more than 31 rows it gives me a error shown below.... I have a trigger attached to the execution table where i am inserting the rows... I am unable to sort out the error.. If anyone knows whats the problem Please reply.... Thank you....
Msg 217, Level 16, State 1, Procedure runtime_insert_elevator_table, Line 105 Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).
I want to select the latest photos that were posted on my site from my photos table:id name usercode createdate1 holiday 5 1/1/20082 holiday2 5 1/1/20083 my car 5 1/1/20084 new home 7 1/1/20085 starry night 8 1/1/20086 me again 6 10/10/2007But in case one user has posted like 400 photos I dont want to show 400 photos of the same user as that would mess up latest photos. So I want to show the latest photos but always with a maximum of 3 for the same user...So in the above data example pictures with id 1,2,3,4,5 would be shownHow can I achieve this with SQL (and as always: without temp tables :))Thanks!
hi...i need a stored procedure query to get the maximum occurred value ie(more than one time occurred value).... this is my table structure.... table Name: PHOTO_GALLERY_VISITSpgv_id pgv_main_category_id pgv_sub_category_id pgv_path pgv_visitor_id pgv_visited_date 6 54 72 photo/Writer/Content/Mobiles/LG/camer4.jpg 26 4/3/2008 6:41:02 PM 7 54 73 photo/Writer/Content/Mobiles/Samsung/mobile1.jpg 26 4/3/2008 6:41:43 PM 8 64 85 photo/Writer/Content/Movie/Bachan/bhachan1.jpg 25 4/4/2008 3:37:17 PM 9 63 82 photo/Writer/Content/sports/Cricket/cricket1.jpg 34 4/4/2008 3:37:29 PM 10 54 73 photo/Writer/Content/Mobiles/Samsung/mobile1.jpg 34 4/4/2008 3:37:29 PM 11 54 73 photo/Writer/Content/Mobiles/Samsung/mobile1.jpg 26 4/4/2008 3:37:29 PM 12 54 73 photo/Writer/Content/Mobiles/Samsung/mobile1.jpg 54 4/4/2008 3:37:29 PM 13 54 72 photo/Writer/Content/Mobiles/LG/camer4.jpg 59 4/4/2008 3:37:17 PM The above is my sample table...... In that filter the most occurrence based on the column "pgv_sub_category_id"in the above table the 73 is the maximum occurred id after that the second maximum ie..72 is the 2nd maximum occurred....hence i want the output as only the id & path which occurred more than one time..... pgv_sub_category_id pgv_path 73 photo/Writer/Content/Mobiles/Samsung/mobile1.jpg 72 photo/Writer/Content/Mobiles/LG/camer4.jpg plz anybody send me the query....its urgent.....thanks in advance.....regardsjanu
what I try is a little bit heavy, maybe, but I only miss the minimum/maximum fuction - or I didn´t found it; not here in the Forum and also not in the onlinehelp of the SQL Server.
What I try to do:
I have 2 columns in my table; a start- and an end-date. For this period of time between end and start i have to calculate the days for the years. Here my thoughts (for the current year):
Is the startdate <= 31.12.2004 and the enddate >= 1.1.2004 i have to calculate die datediff between max(1.1.2004/startdate) and min(31.12.2004/enddate)
like this sqlstatement:
SELECT CASE WHEN dbo.Phases.phasenstart <= CAST(CAST(YEAR(GETDATE()) AS varchar) + '-31-12' AS smalldatetime) AND dbo.Phases.phasenabschlussist >= CAST(CAST(YEAR(GETDATE()) AS varchar) + '-01-01' AS smalldatetime) THEN 365 ELSE 0 END AS Expr2, FROM dbo.Phases WHERE (phasenstart IS NOT NULL) AND (phasenabschlussist IS NOT NULL)
instead of 365 there must be the above calculation. Is start=3.1.2003 and end=30.1.2004 I expect as result only the 30 days in 2004.
Is there a way to alter the default 256 value to some other value in a transac SQL script? The value can be changed manually in the advanced tab of the current connection options. I need to be able to set and reset this value in a script and/or stored procedure. Kind of urgent for an answer to this problem. Thanks in advance.
In a query Analyser, there is a provision to change the "Maximum characters per column 256 " to our size in advanced option.
It works ok.
We are using VisualInterdev for developing ASP's -- there thro ADO - we are getting the rows from sql server 7.0 -- there data more than 256 characters are truncated.
How will i get the actual data ?.. where i can do the settings..?
I am receiving an error from my ODBC driver Maximum number of DBPROCESSes already allocated.
I confirmed that there are 25 connections and that this is the default. This is caused by error message 10029, SQLEDBPS, when the maximum number of simultaneously open DBPROCESS structures exceeds the current setting. I would like to increase this maximum.
I have found only two ways to do this. One is using dbsetmaxprocs using C and the other is using SqlSetMaxProcs using Visual Basic. My problem is that I am interfacing to SQL Server using a third party tool that is doing the lower level programming.
Is there some way that I can increase the maximum number of DB processes for all databases that are part of the SQL Server 7 environment, or can I set this value using a program that is called from a stored procedure?
Any ideas in this area will be greatly appreciated.
We have a production server that is configured to 100 user connections. Without any reason, the maximum connections had been exceeded and users can no longer access the sql. But if you sp_who , it displayed only 4 user connections. Since, I have an open connection before this error happens, i was able to execute sp_who. This happened 4 times since we installed the sql server. the version is 6.50.422 sp5a with hotfix.
To all gurus out there, can you give light into this problem?
if SQL SERVER 2000 only allow 8060 bytes per row, then how can it store images or CLOB data? Is there a way that would let us change the maximum number of bytes per row? Any help would be greatly appreciated. Thanks.
Can any one help me out form this... I just want to know the maximum input a bcp utility can take..... its a direct insert from one table to another but contains millions of data
I have SQL Server 2000 Standard Edition running on Windows 2000 Server. There are always memory full alter. I am going to configure that.
I hope a clearation about a concept. In my enviroment, does SQL Server take maximum memroy upto 2GB, no matter if QWE is enabled?
BOL said AWE is available only in the SQL Server 2000 Enterprise and Developer editions. Does it mean AWE cannot be configured on SQL Server 2000 Standard Edition?