sql-server-2005

SQL 2005 MD5 Hash and C# MD5 Hash

穿精又带淫゛_ 提交于 2020-01-05 08:26:24
问题 I currently have a legacy database (SQL 2005) that generates hash strings for tokens. It does it like this... DECLARE @RowID INT DECLARE @hashString VARCHAR(128) SET @RowID = 12345 SET @salt= 0xD2779428A5328AF9 SET @hashBinary = HASHBYTES(('MD5', @salt + CAST(@RowID AS VARBINARY(30))) SET @hashString = sys.fn_varbintohexstr(@hashBinary) If I execute this, I my hash string looks like this: "0x69a947fd71b853485007f0d0be0763a5" Now, I need to replicate the same logic in C# so I can remove the

Looping through Active Directory to get managers and direct reports

筅森魡賤 提交于 2020-01-05 08:03:29
问题 Go easy on me, this is my first question ;) I've spent a lot of time looking, but I haven't found what I'm looking for. I've got an intranet based reporting tool (VB.Net + ASP.Net Integrated Windows Authentication) that looks up users and managers from a SQL Server 2005 table to roll up the reporting to manager level. This table is currently manually maintained and I've been asked to make it more dynamic as it is going to be up-scaled for far more users. Therefore I'm looking to link in with

Cannot pivot table with my query?

走远了吗. 提交于 2020-01-05 07:58:07
问题 I have a table which looks like this - Id AttributeName AttributeValue A1 Atr1 A1V1 A1 Atr2 A1V2 A1 Atr3 A1V3 A2 Atr1 A2V1 A2 Atr2 A2V2 A2 Atr3 A3V3 Each ID in this table has the exact same attributes, ie ATR1, ATR2, ATR3. The values of these attributes is unique. I want to pivot this table and get the following output - Id Atr1 Atr2 Atr3 A1 A1V1 A1V2 A1V3 A2 A2V1 A2V2 A2V3 How do I do this ? I tried a query and it failed with the error - Msg 156, Level 15, State 1, Line 21 Incorrect syntax

Incrementing sequence number on SQL insert

妖精的绣舞 提交于 2020-01-05 07:57:12
问题 Is there a simple way to insert multiple rows and increment a particular field, using SQL Server 2005? Note, I am not looking for a solution involving an identity column - see the bottom of the question for an explanation (The following schema and data have been replicated here in this SQLFiddle.) For instance, consider the following table and data... CREATE TABLE #TEMPTABLE ( [PKID] INT IDENTITY, [FKID] INT, [MYTEXT] VARCHAR(10), [SEQUENCE] INT ) INSERT INTO #TEMPTABLE ([FKID], [MYTEXT],

How to JOIN to a table that has multiple values in the column?

眉间皱痕 提交于 2020-01-05 07:44:56
问题 I've got a person table that contains an error code field that can contain multiple error codes (001, 002, 003...). I know that's a schema problem but this is a vendor application and I have no control over the schema, so I have to work with what I've got. There is also a Error table that contains ErrorCode (char(3)) and Descript (char(1000)). In my query the Person.ErrorCode is joined to the Error.ErrorCode to get the value of the corresponding description. For person records where there is

How to retrieve column value of sql server table and store it in label.Text of c# ASP.Net

我是研究僧i 提交于 2020-01-05 07:37:59
问题 My question is Suppose I have a Column "fname" whose value is 'Nikhil' in table "profile". How to retrieve column value of sql server table and store it in label.Text of c# ASP.Net. I mean what should be the code if I want label text to be "fname" value that is "Nikhil" Connection is already done properly because I am able to display table data in Gridview. label1.Text = ?; // I want fname here Regards, Nikhil 回答1: Go to MSDN to learn it http://msdn.microsoft.com/en-us/bb188199. Here's a

How to retrieve column value of sql server table and store it in label.Text of c# ASP.Net

元气小坏坏 提交于 2020-01-05 07:37:50
问题 My question is Suppose I have a Column "fname" whose value is 'Nikhil' in table "profile". How to retrieve column value of sql server table and store it in label.Text of c# ASP.Net. I mean what should be the code if I want label text to be "fname" value that is "Nikhil" Connection is already done properly because I am able to display table data in Gridview. label1.Text = ?; // I want fname here Regards, Nikhil 回答1: Go to MSDN to learn it http://msdn.microsoft.com/en-us/bb188199. Here's a

SQL CONCAT IF Statement?

老子叫甜甜 提交于 2020-01-05 07:03:46
问题 Morning All, Im not to sure how i need to solve my following query... I have the following query which pulls back the desired records in SQL server... SELECT agenda.AgendaItemNumber,Agenda.AgendaName, AgendaType.AgendaTypeDescription, userdetails.fullName FROM Agenda JOIN AgendaType ON AgendaType.AgendaTypeID=Agenda.AgendaTypeID JOIN UserDetails ON Agenda.AgendaID = Userdetails.AgendaID WHERE agenda.AgendaTypeID = '2' AND AgendaItemNumber = AgendaItemNumber AND AgendaName = AgendaName AND

where clause from where clause

寵の児 提交于 2020-01-05 06:57:15
问题 i need to do this : There is a table called table1 it has a employee id column,status column which has values 1 and 0 only and a department column with values 100,101,102. i want to list all employeeid with the status = 0 and (department=100 whose status=1) Please help me 回答1: Where Status = 0 or (Department = 100 And Status = 1) 回答2: You can write your condition in SQL almost like you wrote it in english (except you'll use a or instead of a and ) : select * from table1 where status = 0 or

SQL Server 2005 - How can I do a Reg Exp in T-SQL

 ̄綄美尐妖づ 提交于 2020-01-05 06:52:27
问题 Is there any way I can perform a Regular Expression search using T-SQL in SQL Server 2005 without having to load a .Net Assembly? 回答1: It seems that you can do it with VBScript, but it's not very pretty. 回答2: Unfortunately, the only way I know is by using a CLR udf as described in http://msdn.microsoft.com/en-us/magazine/cc163473.aspx 回答3: Dan Farino seems to have written an SP for SQL Server exactly for the purpose of using regex without having to install a .NET framework for CLR. Looks