sql-server-2008-r2

How to update a varbinary field with a specific value?

◇◆丶佛笑我妖孽 提交于 2019-11-29 11:17:49
问题 Basically I am trying to give a user a certain password so I can test some functionality on a system, as I only have our admin account and I can't play with that I am just picking a random account so I can do my testing. So here is my attempt at an update: UPDATE dbo.Login SET Salt=CAST('bPftidzyAQik' AS VARBINARY), Password=CAST('0x2B89C2954E18E15759545A421D243E251784FA009E46F7A163926247FDB945F85F095DBB1FFF5B2B43A6ADAE27B8C46E176902412C4F8943E39528FF94E0DD5B' AS VARBINARY) WHERE LoginID

SQL Server Agent gives- Remote procedure call failed (0x800706be)

人走茶凉 提交于 2019-11-29 10:56:21
问题 Does Anyone knows the solution to this problem m not being able to run the SQL Server Services. 回答1: With all due respect, "Right click on configuration manager and run as administrator" is a bogus answer. I also have this problem with the following series of events: I download the Windows Azure SDK from here: http://www.windowsazure.com/en-us/develop/downloads/, which installs SQL 2012 express; immediate I try to run SQL Server Configuration Manager, and the installation of SQL 2012 has

'MOD' is not a recognized built-in function name

ぐ巨炮叔叔 提交于 2019-11-29 10:46:34
问题 I wanted to use MOD function in SQL Server 2008R2 and followed this link but still got the message: 'MOD' is not a recognized built-in function name. DECLARE @m INT SET @m = MOD(321,11) SELECT @m Error: Msg 195, Level 15, State 10, Line 2 'MOD' is not a recognized built-in function name. Why I can't use this function from the link above? 回答1: The MOD keyword only exists in the DAX language (tabular dimensional queries), not TSQL Use % instead. Ref: Modulo 回答2: In TSQL, the modulo is done with

Query AD Group Membership Recursively Through SQL

北慕城南 提交于 2019-11-29 10:23:11
Background I'm creating some SQL to assist with security auditing; this will take security info from various systems databases and from Active Directory and will produce a list of all anomalies (i.e. cases where accounts are closed in one system but not others. Current Code To get a list of users who are a member of a security group I run the below SQL: if not exists(select 1 from sys.servers where name = 'ADSI') EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'adsdatasource' SELECT sAMAccountName, displayName, givenName, sn, isDeleted --, lastLogonTimestamp --

undocumented CONVERT styles - datetime 23

╄→尐↘猪︶ㄣ 提交于 2019-11-29 10:18:01
问题 Recently I stumbled upon CONVERT function style 23, which is very handy as it gives you DATE in format yyyy-mm-dd . The problem is that it's not documented in msdn! (link from SSMS help after F1 on CONVERT: http://msdn.microsoft.com/en-us/library/ms187928%28SQL.105%29.aspx). Example: select convert( date ,'2012-01-30', 23) select convert(varchar(255), getdate(), 23) This style is very useful and I've been missing it, but my concerns are: - Is it safe to use? Is it deprecated or sneak in by

Calling an in-line TVF with named parameters, what is the proper syntax?

落爺英雄遲暮 提交于 2019-11-29 10:12:13
I tried calling an in-line TVF with positional parameters and it works fine: SELECT MyTable.Col1, (SELECT TvfColumn FROM ufnGetData(MyTable.Col1, MyTable.Col2)), MyTable.Col2 FROM MyTable Then I tried to name the parameters to the TVF and it does not parse: SELECT MyTable.Col1, (SELECT TvfColumn FROM ufnGetData(@Param1=MyTable.Col1, @Param2=MyTable.Col2)), MyTable.Col2 FROM MyTable The function looks something like: CREATE FUNCTION dbo.ufnGetData ( @Param1 INT, @Param2 INT ) RETURNS TABLE AS RETURN ( SELECT blah blah blah AS TvfColumn ) GO Giving an error similar to: Msg 137, Level 15, State 2

Determine table referenced in a view in SQL Server

不羁的心 提交于 2019-11-29 09:24:35
问题 How can i get to know the tables used in a view in SQL Server? Is there a script or a tool that could let me know the tables used in a view and can also list down the fields? Hope this clears the question. Let me know if not. Please guide! Thanks! 回答1: select cols.* from sys.sql_expression_dependencies objs outer apply sys.dm_sql_referenced_entities ( OBJECT_SCHEMA_NAME(objs.referencing_id) + N'.' + object_name(objs.referencing_id), N'OBJECT' ) as cols where objs.referencing_id = object_id(

Efficient query to split a delimited column into a separate table

孤人 提交于 2019-11-29 08:42:01
I have some data that includes a column with delimited data. There are multiple records in the same column essentially: A0434168.A2367943.A18456972.A0135374.A0080362.A0084546.A0100991.A0064071.A0100858 The values are of variable length, and delimited by periods. I've been attempting to create a lookup table for this data, using a cursor. Due to the volume of data, the cursor is unreasonably slow. My cursor looks like the following: DECLARE @ptr nvarchar(160) DECLARE @aui nvarchar(15) DECLARE @getmrhier3 CURSOR SET @getmrhier3 = CURSOR FOR SELECT cast(ptr as nvarchar(160)),aui FROM mrhier3

How to convert a SQL Server cursor to MySQL equivalent

空扰寡人 提交于 2019-11-29 08:19:21
How can I convert the procedure below to MySQL format? Here is the piece to be converted: DECLARE @CurrentFirstName varchar(300) DECLARE @CurrentAge INT DECLARE CursorName CURSOR FAST_FORWARD FOR SELECT Firstname,Age FROM Customers OPEN CursorName FETCH NEXT FROM CursorName INTO @CurrentFirstName, @CurrentAge WHILE @@FETCH_STATUS = 0 BEGIN IF @AGE>60 /*this is stupid but we can apply any complex condition here*/ BEGIN insert into ElderCustomers values (@CurrentFirstName,@CurrentAge) END FETCH NEXT FROM CursorName INTO @CurrentFirstname,@CurrentAge END CLOSE CursorName DEALLOCATE CursorName

JTDS driver not working for Sql Server 2008R2 and Denali Native SSPI library not loaded. Check the java.library.path system property

杀马特。学长 韩版系。学妹 提交于 2019-11-29 06:49:55
I am trying to connect Sql Server Data Base using windows authentication from my application using JTDS driver but i got following error SSO Failed: Native SSPI library not loaded. Check the java.library.path system property. Following are the scenarios where i tried to resolve but still something is missing.. i have added ntlmauth.dll in system directory and it works fine for Sql server 2005. But the same thing i tried for Sql Server 2008 R2 and Denali but it gives me the same error as i mentioned above Also i considered bit i mean i copied ntlmauth.dll from x64\SSO\ path in system directory.