sql-server-2012

SQL Server 2012 SQLPs Module - Changing current location automatically?

别说谁变了你拦得住时间么 提交于 2019-12-21 07:06:50
问题 I have a large library of existing powershell scripts, primarily to run some complicated logic and interactions between SQL Server and the file system. The SQL interactions typically are performed through the cmdlet Invoke-SQLCmd . Recently the SSMS version on all of my servers was upgraded to 2012. This meant I had to make some changes to my code to remove references to the sqlserverprovidersnapin100 and sqlservercmdletsnapin100 since those are deprecated in 2012 in favor of importing the

SQL Server: datediff function resulted in an overflow when using MILLISECOND

我与影子孤独终老i 提交于 2019-12-21 06:59:25
问题 I have the following query : select CONVERT(varchar(12), DATEADD(MILLISECOND, DateDiff(MILLISECOND, '2014-08-04 10:37:28.713','2014-11-04 08:21:17.723'), 0), 114) When I execute this, I get the error : "The datediff function resulted in an overflow. The number of dateparts separating two date/time instances is too large. Try to use datediff with a less precise datepart." When I change the query to the following it works fine : select CONVERT(varchar(12), DATEADD(SECOND, DateDiff(SECOND, '2014

How can I restore a database backup file (.bak) from SQL Server 2012 into SQL Server 2008 Express?

吃可爱长大的小学妹 提交于 2019-12-21 06:50:10
问题 A database that was originally from SQL Server 2008, was restored into SQL Server 2012. A backup from SQL Server 2012 was made and I am trying to restore it on my local SQL Server 2008 Express. However I get an error 'Specified cast is not valid' (SQLManagerUI). I have generated an SQL Script from 2012 and set it so that it will generate with compatibility to SQL Server 2008. However it is a large sql file, around 700mb. I recall before that I had tried to run a script of that size before on

Django SQLServer [FreeTDS][SQL Server]The data types nvarchar(max) and ntext are incompatible in the equal to operator

微笑、不失礼 提交于 2019-12-21 05:15:20
问题 I am getting the following error on doing django model.objects.get_or_create . SQLServer [FreeTDS][SQL Server]The data types nvarchar(max) and ntext are incompatible in the equal to operator. The column django is complaining about is NVARCHAR(MAX) with null allowed in SQLServer (which was auto created by Django migration). The Django model element is defined as TextField(null=True) 来源: https://stackoverflow.com/questions/39055935/django-sqlserver-freetdssql-serverthe-data-types-nvarcharmax

Get next minimum, greater than or equal to a given value for each group

落爺英雄遲暮 提交于 2019-12-21 05:07:14
问题 given the following Table1: RefID intVal SomeVal ---------------------- 1 10 val01 1 20 val02 1 30 val03 1 40 val04 1 50 val05 2 10 val06 2 20 val07 2 30 val08 2 40 val09 2 50 val10 3 12 val11 3 14 val12 4 10 val13 5 100 val14 5 150 val15 5 1000 val16 and Table2 containing some RefIDs and intVals like RefID intVal ------------- 1 11 1 28 2 9 2 50 2 51 4 11 5 1 5 150 5 151 need an SQL Statement to get the next greater intValue for each RefID and NULL if not found in Table1 following is the

SSRS shows no records in report but query returns results

余生长醉 提交于 2019-12-21 04:54:09
问题 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

Recursively retrieve LAG() value of previous record

谁说我不能喝 提交于 2019-12-21 04:48:13
问题 I've made the following calculation involving LAG(): (lag(fValue,1,fValue) OVER (PARTITION BY Cluster ORDER BY iSequence) + fValue) / 2 as fValueAjusted It takes the previous (based on iSequence) record's fValue, sums with current one, and divides it by 2. But, instead of using fValue, I must do that using previous record's fValueAjusted. It means that first record's fValueAjusted will be its own fValue. Second record's fValueAjusted will be based on first record's fValue. And, starting from

SQL Server - PIVOT - two columns into rows

╄→гoц情女王★ 提交于 2019-12-21 04:13:28
问题 I saw many questions about PIVOT for a single column, each question more complex than other, however, I could not find anything like what I need. To be honest, I don't even know if pivot will help me in this situation. Let's say I have this data on my source table: SELECT '1' as 'RowId', 'RandomName1' as 'First', 'RandomLast1' as 'Last' UNION SELECT '2' as 'RowId', 'RandomName2' as 'First', 'RandomLast2' as 'Last' UNION SELECT '3' as 'RowId', 'RandomName3' as 'First', 'RandomLast3' as 'Last'

PHP 5.5 and MSSQL driver: Installing ODBC Driver 11 in Windows Server 2012 R2

南笙酒味 提交于 2019-12-21 04:06:13
问题 I have a Windows Server 2012 R2 with IIS 8.5, and another server with MSSQL 2012. I must install PHP in IIS and connect to MSSQL, and I don't have Internet available for Web PI. I managed to install PHP 5.5 and I'm able to run phpinfo() , and I also assured that php.ini is being loaded from C:\php\php.ini . I was also able to load sqlsrv driver, it reports in example sqlsrv.ClientBufferMaxKBSize 10240 10240 . But when I execute a php file that connects to DB, I get a message This extension

How do I import a .bak file into Microsoft SQL Server 2012?

牧云@^-^@ 提交于 2019-12-21 03:10:40
问题 Been Googling this for awhile and no answer....can anyone help? 回答1: For SQL Server 2008, I would imagine the procedure is similar...? open SQL Server Management Studio log in to a SQL Server instance, right click on "Databases", select "Restore Database" wizard appears, you want "from device" which allows you to select a .bak file 回答2: Using the RESTORE DATABASE command most likely. bak is a common extension used for a database backup file. You'll find documentation for this command on MSDN.