sql-server-2012

Unrelated result in the output?

我们两清 提交于 2019-12-11 13:22:26
问题 this is my query: SELECT TOP 10000 [Service_order] ,[COMPANY] ,[PENDING_DAYS] ,[SERVICE_TYPE] ,[SERVICE_TYPE_TXT] ,[STATUS] ,[STATUS_TEXT] ,[REASON] ,[REASON_TEXT] ,[ASC code] ,[ASC name] ,[MODEL] ,[INOUTWTY] ,[Part_code1] ,[PS1] ,[confirmation_No1] ,[Part_code2] ,[PS2] ,[SO_NO2] ,[Part_code3] ,[PS3] ,[SO_NO3] ,[Part_code4] ,[PS4] ,[SO_NO4] ,[Part_code5] ,[PS5] ,[SO_NO5] ,[Engineer name] FROM ['NewLP'] where REASON_TEXT = 'Parts Not available (ASC)' or REASON_TEXT = 'Parts In Transit (Samsung

SQL Server BLOB image column - extracting with BCP queryout - corrupted files AND bug

余生颓废 提交于 2019-12-11 12:51:18
问题 I need to export pdf and image files from a column in SQL Server 2012. Jonas's 3-step process in "How to export an image column to files in sql server" is the clearest instruction I've found. I did everything exactly as he stated. Two notes: Where he says "your_db" in the BCP statement, you need database_name.schema_name.table_name. No line breaks are allowed. I was able to export files one at a time after this, but they were corrupt. The files were slightly smaller (by 1-15 KB) than the

Table Valued Function vs Scalar Values Function for single return Value

旧城冷巷雨未停 提交于 2019-12-11 12:32:56
问题 I am returning single value from a scaler function as below: CREATE FUNCTION [dbo].[GetNoOfAssignedCases] ( @UserID INT, @FromD DATETIME, @ToD DATETIME ) RETURNS NVARCHAR(MAX) AS BEGIN DECLARE @CaseCount INT = 0 SELECT @CaseCount = COUNT(1) FROM Cases WHERE CaseAssignedToAssessor = @UserID AND CAST(ActionDateTime AS DATE) >= @FromD AND CAST(ActionDateTime AS DATE) <= @ToD RETURN @CaseCount END And using it as below: SELECT [Name], [DBO].[GetNoOfAssignedCases](UserID, GETDATE()-30, GETDATE())

Invalid Column name but still working

元气小坏坏 提交于 2019-12-11 12:32:32
问题 When I connect to the server name using it's name SQL is showing red lines under the code and stating things like column invalid or object invalid. But the code stills runs. When I connect to the server using it's IP I do not get the red lines and the code also runs. Can I trust the data when using the name? Also why is it doing this? I am using SSMS 2012 to access a brand new 2012 server. 回答1: Did you make the column since the last time you refreshed your local intellisense cache? Try doing

SqlConnection throws an exception when running without debugging

萝らか妹 提交于 2019-12-11 12:25:11
问题 I have an exception every time I try to run my program without debugging (Ctrl+F5). The code seems to run fine with debugging. I have tried creating a temp project with just the essentials. I have reinstalled Visual Studio. The problem still occurs. There is already a post about this but not a clear answer. My Connection String: "Data Source=(localdb)\\ProjectsV12;Initial Catalog=gatdb;Integrated Security=False;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent

Sum up values from databases and parametrize it. [SQL Server]

送分小仙女□ 提交于 2019-12-11 12:13:14
问题 I want to sum up values from several databases. At this moment I have three databases: SPA_PROD , SPB_PROD and SPC_PROD . My SQL query: IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TESTSUM]') AND TYPE IN (N'P',N'PC')) DROP PROCEDURE [dbo].[TESTSUM] GO CREATE PROC TESTSUM AS BEGIN DECLARE @dbName SYSNAME, @ObjectSUM INT, @d datetime SET @d = '20141113' DECLARE @SQL NVARCHAR(MAX) DECLARE @DBObjectStats TABLE ( --DBName SYSNAME, DBObjects INT) DECLARE curAllDBs

How to connect to a high availability SQL Server from Python + SQL Alchemy

若如初见. 提交于 2019-12-11 12:12:34
问题 Our infrastructure group has asked us to "add MultiSubnetFailover=True to all application connection strings" so that we can take advantage of a new SQL Server HA setup involving Availability Groups. I am stuck though since we have some python programs that connect (read+write) to the database via SQL Alchemy. I have been searching and I don't see anything about this MultiSubnetFailover feature being available as an option in SQL Alchemy or any other Python driver. Is it possible to connect

Error installing sql server 2012 Entreprise Edition

。_饼干妹妹 提交于 2019-12-11 11:54:10
问题 I m trying to install sql server 2012 entrprise (or Express ) edition in my computer but i get the this error message: The operating system on this computer does not meet the minimum requirements for SQL Server 2012. For Windows Vista or Windows Server 2008 operating systems, Service pack 2 or later is required. For windows 7 or windows server 2008 R2, Service pack 1 or later is required. For more information, see Hardware and software requirements for installing SQL Server 2012 at http://go

Pivot Dynamic row to Column with output parameter?

百般思念 提交于 2019-12-11 11:35:50
问题 There is no problem for me to pivot statistic columns in my query e.g Column 1 , Column 2 , Column 3.... and so on. But i would like to do this dynamic instead. My data looks like this: i want to be able to EXECUTE a store procedure to get the output result: Exec sp_output 1 (from another window where '1' represents the PoolID (@AppPool)) to look like this: This is my SP: create PROCEDURE [dbo].[sp_test] @Query as nvarchar(100) -- OUTPUT?, @AppPool AS nvarchar(50) AS SELECT @Query = Attribute

SQL Server prompt user for input and pass to variable

喜夏-厌秋 提交于 2019-12-11 10:52:12
问题 I am trying to write code for my client that they can use in the future without my help. They will install SQLServer Express on one of their desktops (like I have been using) so that the designated person can run the pre-written queries on locally stored data for specific information they need on a daily basis. I don't want to get into why we are using SQL Server Express and managing our data in this manner, but trust that we've looked into alternatives and this is the most feasible option. I