sql-server

Pyspark connection to the Microsoft SQL server?

廉价感情. 提交于 2021-02-17 02:47:29
问题 I have a huge dataset in SQL server, I want to Connect the SQL server with python, then use pyspark to run the query. I've seen the JDBC driver but I don't find the way to do it, I did it with PYODBC but not with a spark. Any help would be appreciated. 回答1: Please use the following to connect to Microsoft SQL: def connect_to_sql( spark, jdbc_hostname, jdbc_port, database, data_table, username, password ): jdbc_url = "jdbc:sqlserver://{0}:{1}/{2}".format(jdbc_hostname, jdbc_port, database)

How to get total weight of a case size e.g. 12 x 160g equal to 1.92kg

若如初见. 提交于 2021-02-16 23:43:13
问题 Not sure if this is possible. But, let's say I have a column like this in a table: 12 x 60g 12 x 160g 500g 1kg 1kg 12 x 160g 12 x 250g Some are are individual sizes and some are case sizes. Is it possible to get the total weight for each row? If so, how would it be done? e.g. 0.72kg /* 12 x 0.060 = 0.72 */ 1.92kg /* 12 x 0.160 = 1.92 ... */ 0.5kg 1kg 1kg 1.92kg 3kg 回答1: Adding to the comment by @Tomalak, below is an example script you could use to populate the weight expression translation

SQL Server LocalDB instance fails to start (automatically)

若如初见. 提交于 2021-02-16 21:02:35
问题 I have a WPF application which is connecting to the SQL Server 2014 Express LocalDB (i.e. a local .mdf database file). The application uses the Entity Framework Core library version 7.0.0-rc1-final. This is the connection string that I am using: data source=(LocalDb)\InstanceLocalDB; Initial Catalog = MyAppDB; Integrated Security=True; MultipleActiveResultSets=True; Connection Timeout = 10 I do the installation of the SQL Server LocalDB during the application's setup. The same goes for the

SQL Server: is it possible to get data from another SQL server without setting linked server?

蹲街弑〆低调 提交于 2021-02-16 20:47:31
问题 I need to do the following query (for example): SELECT c1.CustomerName FROM Customer as c1 INNER JOIN [ExternalServer].[Database].[dbo].[Customer] as c2 ON c2.RefId = c1.RefId For some security reason my client doesn't allow me to create a linked server. The user under whom I execute this query has access to both tables. Is it possible to make it work without using linked server? Thanks. 回答1: You could use OPENROWSET, which'll require the connection info, username & password... While I

How to insert PictureBox to Sql Server Database Varbinary(MAX) with C#?

风流意气都作罢 提交于 2021-02-16 20:18:55
问题 I have a table that have a field as Varbinary(MAX) datatype and I want to insert image file from PictureBox into this column. So how can I convert and insert image to Varbinary in Sql Server. Thank for help me. 回答1: You should really show some code, what have you tried... This is only a guess, but it should give you a clue how to insert picture into database: //byte array that will hold image data byte[] imageData = null; using (var ms = new MemoryStream()) { //here is image property of your

Arithmetic overflow error converting expression to data type int for basic statistics

社会主义新天地 提交于 2021-02-16 20:18:16
问题 I am trying to do a basic query that calculates average, min, max, and count. SELECT MIN(column) as min, MAX(column) as max, AVG(column) as avg, count(*) as count FROM database.dbo.table; Where column is of type int , and the database is azure sql standard. and in return, i get an error: "Arithmetic overflow error converting expression to data type int" Why is int getting a casting-to-int problem in the first place? and is there something I can add that will make this work on all numerical

How to insert PictureBox to Sql Server Database Varbinary(MAX) with C#?

故事扮演 提交于 2021-02-16 20:18:01
问题 I have a table that have a field as Varbinary(MAX) datatype and I want to insert image file from PictureBox into this column. So how can I convert and insert image to Varbinary in Sql Server. Thank for help me. 回答1: You should really show some code, what have you tried... This is only a guess, but it should give you a clue how to insert picture into database: //byte array that will hold image data byte[] imageData = null; using (var ms = new MemoryStream()) { //here is image property of your

Unable to launch runtime for 'R' script

巧了我就是萌 提交于 2021-02-16 18:53:27
问题 After installing the Advanced Analytics Extensions in SQL Server 2016 (CTP3) the following error appears in SSMS while executing an R-script: Unable to launch runtime for 'R' script. Please check the configuration of the 'R' runtime. What is the remedy? 回答1: Tried different approaches, but only this worked for me: "C:\Program Files\Microsoft SQL Server\130\R_SERVER\library\RevoScaleR\rxLibs\x64\RegisterRExt" /uninstall Then "C:\Program Files\Microsoft SQL Server\130\R_SERVER\library

SQL Server TOP keyword returns different results

雨燕双飞 提交于 2021-02-16 18:24:28
问题 I have a T-SQL query to a table where I need the top row returned. In MySQL, this is working as expected, but in SQL Server, I am getting a different data returned which is quite puzzling. I have attached three screen shots: 1 of the table design, 1 of the data returned when only viewing top 10 rows and 1 of the data returned when viewing the top 1000 rows. You will notice the very top row contains different information for the name column between the two queries. The only difference in the

SQL Server TOP keyword returns different results

大憨熊 提交于 2021-02-16 18:24:19
问题 I have a T-SQL query to a table where I need the top row returned. In MySQL, this is working as expected, but in SQL Server, I am getting a different data returned which is quite puzzling. I have attached three screen shots: 1 of the table design, 1 of the data returned when only viewing top 10 rows and 1 of the data returned when viewing the top 1000 rows. You will notice the very top row contains different information for the name column between the two queries. The only difference in the