sqlserver
5 Topics"Caller does not have permissions to execute the stored procedure" based on sys procedure
Did create the following procedure on my DB to read SQL Server Log: USE [MyDB] GO ALTER PROCEDURE [OMEGACA].[P_SYS_READ_POL_DEBUG] ( @p_log_no int, @p_search_1 nvarchar(4000), @p_search_2 nvarchar(4000) ) AS BEGIN EXEC sys.sp_readerrorlog @p_log_no, 1, @p_search_1, @p_search_2 ; END; Schema, DB user and Login is granted server role "sysadmin". Execute on the above procedure is granted to a certain MyDB's role. This role is granted to a certain DB user X (and login). When this user tries to execute the procedure above, it receives error: Caller does not have permissions to execute the stored procedure based on sys procedure Question: How can I get the needed permission for user X? ps. Granting sysadmin to X is not liked.37Views0likes1CommentNeed help with an SQL query without using a cursor
Hi there to all SQL gurus So, here is the scenario. I have a #temp table in one of my SQL stored procedures which has only 2 columns, say Customer ID and Profile ID, and it has the below data Customer ID Profile ID 100001 ABCD001 100001 ABCD002 100002 ABCD001 100002 ABCD002 100003 ABCD001 I need to write a query which selects only the Profile ID which is mapped to all the Customer IDs. In this case Customer ID 100001 and 100002 have both ABCD001 and ABCD002, but Customer ID 100003 has only Profile ID ABCD001, so, the output of the SQL should have only ABCD001. How do I do this without using a CURSOR? Would a CTE help? I am not very familiar with CTE, so if the solution is using a CTE, please give your suggestions in more detail. Thanks in advance29Views0likes1CommentQuestion about decimal numbers in SQL Server Management Studio
Hello, everyone, I am new using SSMS, I created a data base. I used the "import flat file option" to import a csv file, in preview data I uncheck the use rich data type detection, in the modify colum section I see that temp and atemp are float, hum is nvarchar(50) I can see the decimal numbers in a text editor and preview data in SSMS. The file has some colums have decimal numbers, this is part of the table in SSMS preview data: After I import the file, I run select * from bike_share_yr_0 , the temp and atem are not decimal numbers I tried using ChatGPT to see if there are something I can change in the configuartions of SSMS, but nothing worked. Other option is doing some calculations like: UPDATE bike_share_yr_0 SET atemp = atemp / 10000; This work fine for few colums, but what happend if a have a lot of files an every colum have decimales like atemp. Is possible to fix and see in SSMS the decimal numbers like in preview data? What can I do to fix that? Thank you for helpingSolved227Views0likes3CommentsPHP PDOStatement::rowCount problem
Hello everyone, I have a problem with the rowCount() in this code: $sqlLoc= "DECLARE @Data2 AS DATE; SET @Data2 = CONVERT(DATE,CONVERT(date, '$dataIncasso'), 102); DECLARE @Data1 AS DATE; SET @Data1 = DATEADD(DAY, $interval, @Data2) SELECT noteincassi.CodLocale,Insegna,Citta FROM [Edera].[dbo].[NoteIncassi],edera.dbo.AnagraficaLocali where DataIncasso=@Data2 AND tipoincasso='6' and AnagraficaLocali.CodLocale=NoteIncassi.CodLocale AND sospeso=0 GROUP BY noteincassi.CodLocale,insegna,Citta ORDER BY Insegna"; $queryLoc=$conn->prepare($sqlLoc,array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL)); //$queryLoc->execute(); if($queryLoc->execute()){ echo $numero=$queryLoc->rowCount(); } $id=0; while($resultLoc=$queryLoc->fetch()){ It will print -1 but the fecth is working and row are returned,so the rest of the code is working fine, it's only the rowcount and I don't understand why. Thank you910Views1like2Comments