tsql

How to call C# function in stored procedure

喜你入骨 提交于 2020-01-29 05:12:48
问题 SQL Server 2005 supports CLR so it means we can use CLR in backend so how to do that, I have some function in c# which do some complex manipulation with date-time variable now I want to use those functions in SP. First of all IS IT POSSIBLE TO DO THIS. 回答1: Yes, it is possible to use .NET in a SQL Server 2005 database. Be aware that the .NET version supported by SQL Server 2005 is 2.0. Here's a link for an introduction to Making a CLR stored procedure using Visual Studio 回答2: Take a look this

How to call C# function in stored procedure

一曲冷凌霜 提交于 2020-01-29 05:12:25
问题 SQL Server 2005 supports CLR so it means we can use CLR in backend so how to do that, I have some function in c# which do some complex manipulation with date-time variable now I want to use those functions in SP. First of all IS IT POSSIBLE TO DO THIS. 回答1: Yes, it is possible to use .NET in a SQL Server 2005 database. Be aware that the .NET version supported by SQL Server 2005 is 2.0. Here's a link for an introduction to Making a CLR stored procedure using Visual Studio 回答2: Take a look this

How do I suppress the results from a stored procedure from within a stored procedure?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-28 06:20:48
问题 I've got a stored procedure (we'll call it A) that calls another stored procedure (we'll call this one B). B includes a SELECT that I do not want to send back to the caller of A. Here is some really rough pseudocode, but it should get the idea across. PROCEDURE A CURSOR CALL B -- I WANT TO SUPPRESS THE RESULTS FROM B END SELECT * END PROCEDURE B Do some interesting things SELECT * END As you can see above, A calls B and B does some things that I want and returns results that I don't care

Most succinct way to transform a CSV string to an table in TSQL?

空扰寡人 提交于 2020-01-28 01:54:09
问题 -- Given a CSV string like this: declare @roles varchar(800) select @roles = 'Pub,RegUser,ServiceAdmin' -- Question: How to get roles into a table view like this: select 'Pub' union select 'RegUser' union select 'ServiceAdmin' After posting this, I started playing with some dynamic SQL. This seems to work, but seems like there might be some security risks by using dynamic SQL - thoughts on this? declare @rolesSql varchar(800) select @rolesSql = 'select ''' + replace(@roles, ',', ''' union

MS SQL Server pivot table with subquery in column clause

坚强是说给别人听的谎言 提交于 2020-01-27 07:46:29
问题 Im sure this is a simple technique although I can't find an answer so far! I have TIMESTAMP | POINTNAME | VALUE 2012-10-10 16:00:00 AHU01 20 2012-10-10 16:00:00 AHU02 25 2012-10-10 16:00:15 AHU01 26 2012-10-10 16:00:15 AHU02 35 etc... ( for approx 800 POINTNAMES) with many pointnames I dont want to list each one in the 'IN' clause of the pivot 'FOR' (as syntax given below) definition but would like to use perhaps a subquery. So what I would like is all the POINTNAME values as columns with A

MS SQL Server pivot table with subquery in column clause

本小妞迷上赌 提交于 2020-01-27 07:46:25
问题 Im sure this is a simple technique although I can't find an answer so far! I have TIMESTAMP | POINTNAME | VALUE 2012-10-10 16:00:00 AHU01 20 2012-10-10 16:00:00 AHU02 25 2012-10-10 16:00:15 AHU01 26 2012-10-10 16:00:15 AHU02 35 etc... ( for approx 800 POINTNAMES) with many pointnames I dont want to list each one in the 'IN' clause of the pivot 'FOR' (as syntax given below) definition but would like to use perhaps a subquery. So what I would like is all the POINTNAME values as columns with A

MS SQL Server pivot table with subquery in column clause

本秂侑毒 提交于 2020-01-27 07:45:31
问题 Im sure this is a simple technique although I can't find an answer so far! I have TIMESTAMP | POINTNAME | VALUE 2012-10-10 16:00:00 AHU01 20 2012-10-10 16:00:00 AHU02 25 2012-10-10 16:00:15 AHU01 26 2012-10-10 16:00:15 AHU02 35 etc... ( for approx 800 POINTNAMES) with many pointnames I dont want to list each one in the 'IN' clause of the pivot 'FOR' (as syntax given below) definition but would like to use perhaps a subquery. So what I would like is all the POINTNAME values as columns with A

Split words with a capital letter in sql

三世轮回 提交于 2020-01-26 16:56:06
问题 Does anyone know how to split words starting with capital letters from a string? Example: DECLARE @var1 varchar(100) = 'OneTwoThreeFour' DECLARE @var2 varchar(100) = 'OneTwoThreeFourFive' DECLARE @var3 varchar(100) = 'One' SELECT @var1 as Col1, <?> as Col2 SELECT @var2 as Col1, <?> as Col2 SELECT @var3 as Col1, <?> as Col2 expected result: Col1 Col2 OneTwoThreeFour One Two three Four OneTwoThreeFourFive One Two Three Four Five One One If this is not possible (or if too long) an scalar

T-SQL left join not returning null columns

拟墨画扇 提交于 2020-01-26 03:58:09
问题 I have 2 tables in T-SQL one with 10 records and one with 11. select tbl.unit, tbl2.unid from tbl1 left join tbl2 on tbl2.UNID = tbl1.UNIT where tbl2.Status = 'Main' group by unit, UNID This only returns 10 records when tbl1 has 11 records. I was expecting the missing record to show a value if UNIT but null for UNID but is just is not there. I cannot figure out why this is the case 回答1: So why would a LEFT JOIN not show all the records from a left side of the join. Is a bug? Most likely not.

Dynamic SQL Query and problems with special characters

懵懂的女人 提交于 2020-01-26 02:04:39
问题 Right now I am running a query to find and replace a dynamic word within a document into a link. It works just fine but returns null when there are some special characters. Currently I am having issues with the dynamic word contains an ampersand '&' Here is part of the content: <p>STEPS:</p> <p> <p>Please refer to <|Cease & Desist|> policy.</p> It is returning a NULL for 'Cease & Desist' Below is the code I am using, what I need is for it to return the entire dynamic word even if it contains