sql-server-2012

SQLCLR Function and System.Runtime.Serialization In GAC

左心房为你撑大大i 提交于 2019-12-04 07:31:38
I've built a SQLCLR function in C# that will deserialize JSON and return a table. The problem I have is getting the correct assemblies within SQL Server 2012. In order to utilize Newtonsoft's deserializer I've had to add the following assemblies to SQL Server: System.ServiceModel.Internals.dll SMDiagnostics.dll System.Runtime.Serialization.dll Newtonsoft.Json.dll This has all gone as planned but when I try to run my function I get the following error: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken

Differences between equal sign(=) and IN with subquery

旧巷老猫 提交于 2019-12-04 06:52:34
I have a query it takes 20 seconds to execute, follow my query: SELECT MATLIGA.COD_MAT_FAMILIA FROM ORCAMENTOS.dbo.OR_1INSUMOS INSUMOS INNER JOIN ORCAMENTOS.dbo.OR_MAT_GRUPOS GRUPOS ON (GRUPOS.EMPRESA='01' AND GRUPOS.FILIAL='01' AND GRUPOS.CODIGO_INTERNO = 'HOT' ) INNER JOIN ORCAMENTOS.dbo.OR_MATERIAIS MATER ON (MATER.EMPRESA='01' AND MATER.FILIAL='01' AND MATER.CODIGO_GRUPO=GRUPOS.ID AND MATER.ID = INSUMOS.COD_INSUMO_MATER ) INNER JOIN ORCAMENTOS.dbo.OR_MAT_LIGACAO MATLIGA ON (MATLIGA.EMPRESA='01' AND MATLIGA.FILIAL='01' AND MATLIGA.CODIGO_MATERIAL = INSUMOS.COD_INSUMO_MATER) WHERE INSUMOS

Alter View within stored procedure

亡梦爱人 提交于 2019-12-04 06:43:33
问题 How can we alter view within a stored procedure ? create procedure createviewupdatepenaltypointsconsecutive as begin alter VIEW consecutive as WITH cte as ( SELECT *, LAG([pointsRewarded], 1) OVER (PARTITION BY [EmployeeID] ORDER BY [WeekNumber]) as prev1_points, LAG([pointsRewarded], 2) OVER (PARTITION BY [EmployeeID] ORDER BY [WeekNumber]) as prev2_points, LAG([pointsRewarded], 3) OVER (PARTITION BY [EmployeeID] ORDER BY [WeekNumber]) as prev3_points FROM week1 ) SELECT *, CASE WHEN

Concatenate the database name in a SQL multipart identifier

末鹿安然 提交于 2019-12-04 06:23:57
问题 I'm writing a stored procedure and I'm trying to concatenate the database name in the multipart identifier after FROM without success. This is one way that I tried but it didn't work INSERT INTO CONTROL_LOGISTICA.dbo.ITEMS_TRAMITE (NRODCTO, TIPODCTO, PRODUCTO, EMPRESA, CODUSUARIO, CODUBICA, CANTIDAD, CCHECK_HIJO) SELECT @pNrodcto, @pTipodcto, M.PRODUCTO, @pEmpresa, @pUsuario, M.CODUBICA, M.CANTIDAD, 0 FROM "@mEmpresa".dbo.MVTRADE M WITH(NOLOCK) -- Here I'm stuck INNER JOIN Dbo.vReporteMercia

Unable to pass multiple values in querystring in .aspx to report at runtime

喜欢而已 提交于 2019-12-04 06:19:27
问题 This should be simple process but now it became annoying issue. I am trying to pass multiple value in query string in my ASP.Net web report in VS2012. The page has to pass multiple values to the report as a parameter . When I sent a single value (for eg: abc,) the data is being pulled up correctly but however when I am passing multiple values separated by a comma (eg abc,xyz) it is not displaying the results These multiple values separated by a comma are being passed to the page as query

How to change SQL Server authorization mode without Management Studio

坚强是说给别人听的谎言 提交于 2019-12-04 06:15:59
Is there a way to change the authorization mode in SQL Server 2008 or 2012 without using the SQL Server Management Studio? Here is what Management Studio does to change the authentication mode from mixed to Windows only: EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 1; And from Windows only back to mixed: EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2; -- only difference is right here You can call the same command from various sources that can

Incorrect syntax near ')'. while creating table [closed]

强颜欢笑 提交于 2019-12-04 06:01:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I am newbie to sqlserver and i have came across an error which is : System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near ')'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolea n breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient

SSRS shows no records in report but query returns results

若如初见. 提交于 2019-12-04 05:35:45
I have a question according to SSRS. I am working with MSSQL Server management studio 2012 and BIDS Visual studio 2008 for the report design. I have a report with some multivalue parameters and a stored procedure in behind which returns the records. Now I've tried to find the problem on the parameter values passed to the stored procedure and a string split function. I looked in the SQL server profiler if the strings get passed in an unexpected form but thats not the case. I ran the exact execution code in the server as a query and got results back. but if i run the report in the preview pane

Table Valued Constructor Maximum rows limit in Select

岁酱吖の 提交于 2019-12-04 05:29:16
I have a Table Valued Constructor through which am Selecting around 1 million records. It will be used to update another table. SELECT * FROM (VALUES (100,200,300), (100,200,300), (100,200,300), (100,200,300), ..... ..... --1 million records (100,200,300)) tc (proj_d, period_sid, val) Here is my original query : https://www.dropbox.com/s/ezomt80hsh36gws/TVC.txt?dl=0# When I do the above select it is simply showing Query completed with errors with showing any error message. Update : Tried to catch the error message or error number using TRY/CATCH block but no use still same error as previous

How can I use LTRIM/RTRIM to search and replace leading/trailing spaces?

久未见 提交于 2019-12-04 05:14:53
I'm in the process of trying to clear out leading and trailing spaces from an NVARCHAR(MAX) column that is filled with prices (using NVARCHAR due to data importing from multiple operating systems with odd characters). At this point I have a t-sql command that can remove the leading/trailing spaces from static prices. However, when it comes to leveraging this same command to remove all prices, I'm stumped. Here's the static script I used to remove a specific price: UPDATE *tablename* set *columnname* = LTRIM(RTRIM(2.50)) WHERE cost = '2.50 '; Here's what I've tried to remove all the trailing