sql-server-2008-r2

SQL Server: Cannot find data type date and unable to set compatibility

人盡茶涼 提交于 2019-12-10 15:45:25
问题 I have a install script that uses DATE. I'm running SQL Server 2008 R2, and it doesn't like the date type. Msg 2715, Level 16, State 7, Line 1 Column, parameter, or variable #3: Cannot find data type date. So I tried setting the compatibility of the database to 100 using the following: ALTER DATABASE znode_multifront SET COMPATIBILITY = 100 I receive the following error: Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '100'. So I tried going into SQLCMD mode and used the following:

Flat file connection manager carriage return/line feed discrepancy

廉价感情. 提交于 2019-12-10 15:38:29
问题 I'm upgrading from SQL Server 2008R2 to 2017, and making the same jump with SSIS. There are a number of flat file imports that are picking up files that have carriage return/line feeds ( {CR}{LF} ) embedded within a column in the row. The 2008R2 flat file connection manager ignores the embedded {CR}{LF} s that are within a row, but the flat file connection manager in 2017 is treating each {CR}{LF} as a new line. It's the same in an upgraded connection manager or a brand new one that I make

How long should a Primary Key delete take?

99封情书 提交于 2019-12-10 15:15:58
问题 Picture a simple table structure: Table1 Table2 ---------- ---------- ID<-------| ID Name |-->Table1ID Name Table1 has a few million rows (say 3.5 million for example). I issue a delete by Primary Key: DELETE FROM Table1 WHERE ID = 100; There is no row in Table2 that references Table1 with ID = 100 , so the delete works without violating any Foreign Key constraints. How long would you expect the delete to take? On the order of a few milliseconds? A few hundred milliseconds? A second or more?

How can I use SSIS to add an extra column containing the value of an incremented variable into my destination table?

自古美人都是妖i 提交于 2019-12-10 14:54:58
问题 I have this SSIS workflow defined. After I explain what I'm doing, it might be possible my approach is wrong, as this is my first "real" SSIS package. To increment the counter I do this: public void Main() { int i = Convert.ToInt32(Dts.Variables["User::DayCounter"].Value.ToString()); i++; Dts.Variables["User::DayCounter"].Value = i; Dts.TaskResult = (int)ScriptResults.Success; } My destination table currently looks like this: PID Campaign Name Company Impr Clicks Clickthru Leads View-Through

SQL Server - Simultaneous Inserts to the table from multiple clients - Check Limit and Block

我怕爱的太早我们不能终老 提交于 2019-12-10 14:49:09
问题 We are recently facing one issue with simultaneous inserts into one of our sal server tables from multiple clients. I hope you guys can help us through. We are using stored procedure to do the transactions. In that stored procedure, for each transaction, we calculate total sales so far. If the total sales is less than the set limit, then the transaction will be allowed. Otherwise, the transaction will be denied. it works fine most of times. But, sometimes when multiple clients trying to do

Is there a way around the 8k row length limit in SQL Server?

独自空忆成欢 提交于 2019-12-10 14:46:03
问题 First off, I know that in general having large numbers of wide columns is a bad idea, but this is the format I'm constrained to. I have an application that imports CSV files into a staging table before manipulating them and inserting/updating values in the database. The staging table is created on the fly and has a variable number of NVARCHAR colums into which the file is imported, plus two INT columns used as row IDs. One particular file I have to import is about 450 columns wide. With the

SSRS report VERY SLOW in prod but SQL query runs FAST

被刻印的时光 ゝ 提交于 2019-12-10 14:39:35
问题 I've spent hours troubleshooting this and I need some fresh perspective . . . We have a relatively simple report setup in SSRS, simple matrix with columns across the top and data points going down. The SQL query behind the report is "medium" complexity -- has some subqueries and several joins, but nothing real crazy. Report has worked fine for months and recently has become REALLY slow. Like, 15-20 minutes to generate the report. I can clip-and-paste the SQL query from the Report Designer

Return empty or null fields as <element /> from SQL Server 2008 R2 with FOR XML

狂风中的少年 提交于 2019-12-10 14:00:53
问题 I am running a query from SQL Server 2008 R2 using FOR XML PATH . My only issue is that I want ALL elements to appear, even if they are NULL and I want empty (or null) elements to return as <MyElement /> Not as <MyElement></MyElement> 回答1: You can query the field in a sub-query in the filed list, using for xml , create both versions of empty element. declare @T table ( ID int identity primary key, Name nvarchar(10) ) insert into @T(Name) select 'Name 1' union all select null union all select

What is difference between ntext and varchar in SQL Server 2008 R2

无人久伴 提交于 2019-12-10 13:48:47
问题 I want to know basic difference between datatype of ntext and varchar in SQL Server 2008 R2. And in what situation should I use ntext and varchar 回答1: From ntext, text, and image (Transact-SQL) i think that the biggest difference that should concern you is ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. 来源: https://stackoverflow.com

sp_whoisactive resulting an unknown query: “Insert Into <table_name> select *,%%bmk%% from <table_name> option (maxdop 1)”

陌路散爱 提交于 2019-12-10 13:47:24
问题 sp_whoisactive resulting an unknown query: insert into <table_name> select *,%%bmk%% from <table_name> option (maxdop 1) I have checked the above code block but did not find this code in any of my procedures. Can anyone please suggest what this query might be doing. 回答1: This is a clustered index being rebuilt. %BMK% is the function that maps the old bookmarks to the new. There is a document here that discusses the process: https://technet.microsoft.com/en-in/library/cc966402(en-us).aspx 回答2: