sq

CLR assembly will not load in 64 bit SQL Server 2005

匿名 (未验证) 提交于 2019-12-03 02:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We use an assembly with some user defined functions in our installation of SQL Server 2005 (32 bit). We deploy this to production with a script like this: CREATE ASSEMBLY [Ourfunctions] AUTHORIZATION [dbo] FROM 0x4D5A9000...000 WITH PERMISSION_SET = SAFE GO CREATE FUNCTION [dbo].[GLOBAL_FormatString](@input [nvarchar](4000)) RETURNS [nvarchar](4000) WITH EXECUTE AS CALLER AS EXTERNAL NAME [Ourfunctions].[UserDefinedFunctions].[GLOBAL_FormatString] GO We have never experienced any problems with these functions. Now, when we tried to upgrade

How to check if a column exists in a SQL Server table?

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to add a specific column if it is does not exist. I have something like this, but it always returns false: IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTableName' AND COLUMN_NAME = 'myColumnName') How can I check if a column exists in a table of SQL Server database? 回答1: SQL Server 2005 onwards: IF EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'columnName' AND Object_ID = Object_ID(N'schemaName.tableName')) BEGIN -- Column Exists END Martin Smith's version is shorter: IF COL_LENGTH('schemaName.tableName',

Altering user-defined table types in SQL Server

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I alter a user-defined table type in SQL Server ? 回答1: As of my knowledge it is impossible to alter/modify a table type.You can create the type with a different name and then drop the old type and modify it to the new name Credits to jkrajes As per msdn , it is like 'The user-defined table type definition cannot be modified after it is created'. 回答2: This is kind of a hack, but does seem to work. Below are the steps and an example of modifying a table type. One note is the sp_refreshsqlmodule will fail if the change you made to the

P-value from Chi sq test statistic in Python

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have computed a test statistic that is distributed as a chi square with 1 degree of freedom, and want to find out what P-value this corresponds to using python. I'm a python and maths/stats newbie so I think what I want here is the probability denisty function for the chi2 distribution from SciPy. However, when I use this like so: from scipy import stats stats.chi2.pdf(3.84 , 1) 0.029846 However some googling and talking to some colleagues who know maths but not python have said it should be 0.05. Any ideas? Cheers, Davy 回答1: Quick

How to get the row number of ID of a sql table? [closed]

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: suppose i need to print the 3rd, 5th, 9th, 20th, 34th and so on... 回答1: Rows, by position, have no real meaning in a database (at least I can't think of any). Why do you care its actual row location? How do you know that 3rd record is the record you want to delete? Match an ID, match a phrase in another field, do something to uniquely identify the record as the record you want to access. Doing this by it row location will not do this for you. If you have five records that all match exactly and you only want to delete one then add the LIMIT 1

Multiple goal search on XML nodes in SQL Server

匿名 (未验证) 提交于 2019-12-03 02:35:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Process table in SQL Server like this: workflowXML column has values like this: sample1 (ProcessID=1) workflowXML of sample1: <process> <Event type="start" id="StartEvent_1" name="Start"> <outgoing>SequenceFlow_0z7u86p</outgoing> <outgoing>SequenceFlow_1onkt3z</outgoing> </Event> <task type="" id="Task_0a7vu1x" name="D"> <incoming>SequenceFlow_108ajnm</incoming> <incoming>SequenceFlow_1onkt3z</incoming> <outgoing>SequenceFlow_01clcmz</outgoing> </task> <task type="goal" id="Task_00ijt4n" name="B"> <incoming>SequenceFlow_17q1ecq<

Configure query/command timeout with sqlalchemy create_engine?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The following Python code snippet illustrates the issue: print("starting") # I am trying to configure a query/command timeout of one second. # sqlalchemy docs suggest execution_options but the documented list of options doesn't include a timeout: # http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Connection.execution_options # Below, I am guessing at several likely timeout parameter names: db_engine = create_engine("postgresql://user:pass@server/catalog", execution_options={"timeout": 1.0, "statement_timeout": 1.0

How to Join Mutiple Columns in Spark SQL using Java for filtering in DataFrame

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: DataFrame a = contains column x,y,z,k DataFrame b = contains column x,y,a a.join(b,<condition to use in java to use x,y >) ??? I tried using a.join(b,a.col("x").equalTo(b.col("x")) && a.col("y").equalTo(b.col("y"),"inner") But Java is throwing error saying && is not allowed. Can someone help ? thanks 回答1: Spark SQL provides a group of methods on Column marked as java_expr_ops which are designed for Java interoperability. It includes and (see also or ) method which can be used here: a.col("x").equalTo(b.col("x")).and(a.col("y").equalTo(b.col(

convert selected datetime to date in sqlalchemy

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a database of test records with one column 'test_time' defined as datetime. I want to query how many distinct dates there are as I want to dump test results to csv according to dates. I now have the following: distinct_dates = list(session.query(Test_Table.test_time).distinct()) But this gives me a list of datetime not date. Certainly I can convert it in Python but when I am using sqlite. I did this SELECT DISTINCT DATE(test_time) FROM Test_Table . I cannot come up with the equivalent in sqlalchemy. 回答1: That would be by using the

Highcharts: Make the legend symbol a square or rectangle

匿名 (未验证) 提交于 2019-12-03 02:15:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to Make the legend symbol a square or rectangle for a line graph. Example The line is fine. I dont want change the line width. HTML: <script src="http://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 400px"></div> Javascript: $(function () { var chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'line', }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, plotOptions: { series: { marker: { enabled: false } } }, legend: {