sql-server-2012

is there a way to split a string in sql?

南楼画角 提交于 2019-12-13 23:28:27
问题 i got a column with a value something like this. digits 1,2,3 12,4,5 3,45,56 and i want to split the value in the row into individual, is there any simple way to do this in SQL ? im using vb.net. thanks in advance 回答1: TRY THIS: SELECT GROUP_CONCAT((digits) SEPARATOR ', ') as digits FROM table 来源: https://stackoverflow.com/questions/27144096/is-there-a-way-to-split-a-string-in-sql

SQL Server query to get the number of business days between 2 dates, excluding holidays

旧巷老猫 提交于 2019-12-13 23:19:15
问题 We are using SQL Server. In our CASE WHEN statement, I need to check if the number of days between the 2 dates are > 3 business days (so excluding weekends and holidays). CASE WHEN end_date - start_date > 3 THEN 0 --> this need to exclude weekend and holidays WHEN CODE = 1 THEN 1 WHEN CODE =2 THEN 2 ELSE 3 END AS MyColumn Say I have a holiday calendar table that has column HolidayDates that contains all the holidays, for ex: 12/25/2018, 12/31/2018, etc. HolidayDates 12/25/2018 12/31/2018 So,

Conflict between sql server 2008 r2 and 2012

让人想犯罪 __ 提交于 2019-12-13 21:11:27
问题 I have both SQL Server 2008 r2 and SQL Server 2012 installed, but when I open SQL Server 2008 r2 management studio and enter by (localhost), it's version seems to be 11.0.2218 which is for sql server 2012 management studio, so I can't access or create older tables. Is there any way to change SQL Server management studio? 回答1: Open your SQL Server Configuration Manager, Under SQL Server Network Configuration you will find Protocols for and all the instances that is installed will be there.

I don't see my Oracle OLE Driver in SSIS. Shouldn't it be available?

ε祈祈猫儿з 提交于 2019-12-13 21:01:04
问题 I don't see my Oracle OLE Driver in SSIS. Shouldn't it be available? I'd like to use the Oracle OLE Provider that the 32 bit Oracle Configuration Utility says is installed on my laptop: In SSIS, I when I go to create an OLE Database COnnection and choose the provder, I don't see the Oracle OLE Provider. Shouldn't it be here to select? What am I missing? 来源: https://stackoverflow.com/questions/23331209/i-dont-see-my-oracle-ole-driver-in-ssis-shouldnt-it-be-available

Get the smallest datetime value for each day in SQL database

只谈情不闲聊 提交于 2019-12-13 19:25:11
问题 I have a database that are storing datetime values every minute and I wanna get the smallest value for each day. My query looks like this: SELECT lVehicleId, dtVehicleHistoryDate FROM VehicleHistory WHERE lVehicleId = 1146 AND dtVehicleHistoryDate > '2016-01-01 00:00:00' AND dtVehicleHistoryDate < '2016-01-31 00:00:00' AND ((dtTimeReceived - dtVehicleHistoryDate) > '00:30:00') And my values is disposed like this: Id History date 1146 2015-01-26 23:03:50.000 1146 2015-01-26 23:04:50.000 1146

SQL CLR Function to replace TRY_CONVERT

牧云@^-^@ 提交于 2019-12-13 19:16:05
问题 I am trying to write my own CLR function to replace the built in 'TRY_CONVERT' sql function as I need more control over how dates and numbers are converted (e.g. the built-in function can't handle DECIMAL conversions that contain scientific notation). I have tried this: [SqlFunction(IsDeterministic = true, IsPrecise = true)] public static object TRY_CONVERT(SqlDbType type, SqlString input) { switch (type) { case SqlDbType.Decimal: decimal decimalOutput; return decimal.TryParse(input.Value,

How to use DELETE with EXCEPT clause?

荒凉一梦 提交于 2019-12-13 18:59:17
问题 I'm trying to do some ETL from some single tenant DBs (per client) to a multi-tenant DB (all clients, or "global"). In the global DB, I'm trying to maintain a lookup table that identifies users that are associated with a client. So I have this: Database: Global Tables: Users and ClientUsers Database: Client Tables: Users After some other ETL operations, I want to clean up the ClientUsers table by deleting any Users that no longer exist in the Client.Users table. I thought this would work:

tsql login failed but management studio can connect

纵饮孤独 提交于 2019-12-13 18:36:10
问题 I'm trying to connect to a MS SQL Server instance using tsql (to troubleshoot not being able to connect with django-pymssql). I can connect fine to the server (running on Amazon RDS, latest SQL Server version from on there) from a VM running SQL Server management studio, but from my native Ubuntu 15.10 env I get a login failed error. Using the following: tsql -H <hostname> -p 1433 -U <user> -P <mypassword> I get: locale is "en_GB.UTF-8" locale charset is "UTF-8" using default charset "UTF-8"

How to use SQL outfile command correctly?

岁酱吖の 提交于 2019-12-13 17:22:49
问题 I couldn't find an answer so far. What I want to do is to outfile my sql table into a .txt file or csv. (txt if possible) What i try is : SELECT * FROM [mydb] INTO OUTFILE 'd:\scripts\powershell\123.txt'; the return is : Incorrect syntax near the keyword 'INTO'. I also tried to select just some of the columns. Also tried to create the text file first... I use SQL-Server-2012 回答1: goto your Database right click DataBase --> Right Click --> Tasks --> ExportData Sql Server Import/Export Wizard

Split string in column and add value in column

穿精又带淫゛_ 提交于 2019-12-13 17:10:58
问题 I have a table with several rows of data like this : 16 W:\2-Work\ALBO\00_Proposal\ALxO_Amendement #1_20091022_signed.pdf 17 W:\2-Work\ALBO\00_Proposal\Level1\ALBO_Amendment #1_20110418.docx 18 W:\2-Work\ALBO\00_Proposal\A\BR\T\X_#1_20110418_final.docx 19 W:\2-Work\ALBO\MyOptionl\AO_Amendment_2 August 2013.docx I have created columns from Col1 to Col10 I would like to separate each value with the delimiter '\' The idea is to have on each column : Col1 | Col2 | Col3 | Col4 | Col5 |etc... W: 2