sql-server-2014

Call Procedure for each Row without using a cursor and set the row with the result of the procedure

谁说胖子不能爱 提交于 2019-12-02 11:41:33
问题 I have this procedure : CREATE PROC dbo.##HTMLtoMARKDOWN @text nvarchar(500), @returnText nvarchar(500) output AS BEGIN DECLARE @counter tinyint SET @counter=1 WHILE CHARINDEX('**', @text, 1) > 0 BEGIN SELECT @text = STUFF(@text, CHARINDEX('**', @text, 1), 2, IIF(@counter%2=0,'<br><b>','</b>')), @counter = @counter + 1 END SET @returnText = @text END GO Which can be run like this: DECLARE @returnText nvarchar(500) EXEC dbo.##HTMLtoMARKDOWN '**a** **b** **c**', @returnText output I'm using

How to create function for count number of tags in SQL Server

荒凉一梦 提交于 2019-12-02 11:19:35
In SQL Server 2014, I need a function that can count the number of tags, and if not equal the number of tags open and close tags, tag if the tag is low, add the appropriate package. For this example or source code of page of website: <div> <ul> <li>John</li> <li>sara</li> <li>mack</li> <li>jane<li> </div> count ( < ) = count ( > ) count ( <tag> ) = count ( </tag> ) if count( < ) < count( > ) --> add < before element of tag if count( <tag> ) > count( </tag> ) then add </tag> in correct position or delete. The fact, that you tag your question with xml (and the same with your other question you

Flatten table rows into columns in SQL Server [duplicate]

巧了我就是萌 提交于 2019-12-02 09:29:50
This question already has an answer here: Insert and update in a cursor in SQL Server 1 answer I have the below SQL table which has the data generated randomly Code Data SL Payroll 22 SL Payroll 33 SL Payroll 43 .. ..... I want to transfer the data so the format becomes as shown below Code Data1 Data2 Data3 .. SL Payroll 22 33 43 .... Someone suggested Pivot table to transform the data as below SELECT Code, [22] Data1, [33] Data2, [43] Data3 FROM ( SELECT * FROM T ) TBL PIVOT ( MAX(Data) FOR Data IN([22],[33],[43]) ) PVT but this assumes the data points are static like 22,33 but they are

How to loop statements in SQL Server

不打扰是莪最后的温柔 提交于 2019-12-02 08:51:23
I am new to SQL Server, I am trying to do something as follows. Sample code : SELECT ITEM_ID FROM 'TABLE_NAME_1' WHERE ITEM_STATUS = 'ACTIVE' SET @ITEM_PRICE = (SELECT PRICE FROM 'TABLE_NAME_2' WHERE 'PRODUCT_ID' = 'ITEM_ID') INSERT INTO 'TABLE_NAME_3' (ITEM_ID, PRICE) VALUES (@ITEM_ID, @ITEM_PRICE) The first statement will return multiple rows of ITEM_ID By using the ITEM_ID I need to select the ITEM_PRICE from another table using the second statement By using the third statement, I need to insert the data into the third table Here the first statement returns only one ITEM_ID , then

Create function to split delimited seperated data for all records in the table [duplicate]

。_饼干妹妹 提交于 2019-12-02 08:32:37
This question already has an answer here: Delimited Function in SQL to Split Data between semi-colon 2 answers Turning a Comma Separated string into individual rows 14 answers I have Input like this- select ID,FIELD from TABLE 1| A,B,C,D 2|X,Y,Z Output like this- SELECT ID,FIELD from TABLE 1|A 1|B 1|C 1|D 2|X 2|Y 2|Z Could someone please help me as how can I do it in SQL Server 2014 in an easy way ? You can choose a string splitting function from Aaron Bertrand's Split strings the right way – or the next best way , and use it with cross apply to select the data from your table. For this

SQL Service Broker - communication scenario - migration from SQL 2008 R2 to SQL 2014

大憨熊 提交于 2019-12-02 07:44:44
问题 Summary: Is there anything new in SQL Server 2014 (versus 2008 R2) that does not allow the following scenario? Can the same approach be transfered to the new server? The application uses SQL Service Broker to collect data from satellite SQL Express machines (technology computers, now two, soon 4, and possibly more) to the central SQL Server with SQL Server Standard edition. It is based on simplified security settings without the need to exchange certificates. I was asked to migrate the

(Unfixable) Assembly exists on SQL Server 2014 but it claims it doesn't have it

只谈情不闲聊 提交于 2019-12-02 07:21:15
Update: this problem is not fixable: https://connect.microsoft.com/SQLServer/Feedback/Details/809697 I'm attempting to create a SQL CLR assembly with .net 4.5 and it's telling me it's missing system.servicemodel (even though it's in the .net assembly folders): Assembly 'MySQLCLRProject' references assembly 'system.servicemodel, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation

Call Procedure for each Row without using a cursor and set the row with the result of the procedure

和自甴很熟 提交于 2019-12-02 04:39:56
I have this procedure : CREATE PROC dbo.##HTMLtoMARKDOWN @text nvarchar(500), @returnText nvarchar(500) output AS BEGIN DECLARE @counter tinyint SET @counter=1 WHILE CHARINDEX('**', @text, 1) > 0 BEGIN SELECT @text = STUFF(@text, CHARINDEX('**', @text, 1), 2, IIF(@counter%2=0,'<br><b>','</b>')), @counter = @counter + 1 END SET @returnText = @text END GO Which can be run like this: DECLARE @returnText nvarchar(500) EXEC dbo.##HTMLtoMARKDOWN '**a** **b** **c**', @returnText output I'm using this kind of query: Select, IIF(IsUniversal=0,'TRUE','FALSE') as [Is Universal?], MarkdownMini as [Off

RESTORE HEADERONLY Error 3013 after the sp1 was applied to SQL Server 2014

让人想犯罪 __ 提交于 2019-12-01 22:40:23
问题 I have recently applied SP1 to SQL Server 2014, done and dusted, no issue. Few weeks later, when trying to use one of my Stored Procedures to restore one of the databases from a bak file from the network, the following error message was thrown: Error RESTORE HEADERONLY is terminating abnormally. Error 3013. Within the stored procedure, I have the following two lines of code to get the database name from the bak file. SET @strCheck = N'RESTORE HEADERONLY FROM DISK ='''+@backupFile+''''; INSERT

Why does the SqlPublish target fail for a SQL Server 2014 database project?

喜你入骨 提交于 2019-12-01 21:44:52
问题 My machine has the current (March 2014) version of SSDT, Visual Studio 2012 Professional, and SQL Server 2014 Developer. I have a SQL Server project (let's call it MyProject.sqlproj ) that targets SQL Server 2014. I attempted the following: MsBuild.exe MyProject.sqlproj /t:SqlPublish /p:SqlPublishProfilePath=Somewhere.publish.xml This fails with the following error: Deploy error Deploy 72002: Internal Error. The database platform service with type Microsoft.Data.Tools.Schema.Sql