Tag: sql-server

ROUND T-SQL of values 0.0

I am working on a Select statement where I have to show the average of genres but the result must show the 0 values as 0.0 My code is SELECT genreName AS ‘Genre’ , CAST(CASE WHEN AVG(rateValue) IS NULL THEN 0 ELSE ROUND(FORMAT(AVG(rateValue),2),0.0) END AS FLOAT) AS ‘Average Rating’ FROM [IMDB].[FilmGenre] flmgnr LEFT JOIN [IMDB].[FilmGenreAllocation] […]

SQL Query – Grouping/Aggregating Across multiple Tables

select D.[Date], E.emp_name, E.emp_jde, count(C.[agent_no]) calls, count(S.[EMPJDENUM]) sales from (select cast([start_date] as date) dte, [agent_no] from call_table where [skill_name] like ‘%5700 sales l%’ and [Agent_Time] != ‘0’ ) C full outer join (select [AC#DTE_dt], [EMPJDENUM] from sales_table where [ICGCD2] in (‘LAWN’, ‘HORT’) and [CHANNEL]= ‘INQ’ and [ITMQTY]>3 ) S on c.dte=s.[AC#DTE_dt] right join (select [Date] […]

Call to undefined function sqlsrv_connect() with PHP 7 and SQL 2016 Express

I have read a few posts referring to older versions of PHP and MS SQL connectivity but does not seem able to help me with my similar issue. I am running… Windows Server 2012 PHP 7.09 MS SQL 2016 Express I have installed the following drivers from Microsoft php7.dll php_pdo_sqlsrv_7_nts_x64.dll php_sqlsrv_7_nts_x64.dll (Microsoft seems to have […]

Java 7 SSL connection to SQL Server 2014 from Tomcat

I am trying to connect to SQL Server 2014 with Java 7 via JDBC driver and the error that the app throws is : The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “SQL Server returned an incomplete response. The connection has been closed.” My […]

Inserting multiple data tables from stored procedure into strongly typed/named dataset

I have a SQL Server stored procedure that returns several tables. I am accessing these in VB via a data adapter with table mapping in the following method: da.SelectCommand = sqlCommand da.TableMappings.Add(“Table”, “SettingsTable”) da.TableMappings.Add(“Table1”, “MainDataTable”) da.Fill(dsResult) The issue I have here is around the source table name. These automatically generate as Table, Table1, Table2 etc. […]

How can I select fields from Cronus Sales Invoice Header table using php sqlsrv?

I am trying to connect and select all fields on the Sales Invoice Header table and echo only the ‘No_’ field. I am using php with the sqlsrv extension. When I run it I get this error: Array ( [0] => Array ( [0] => 42S02 [SQLSTATE] => 42S02 [1] => 208 [code] => 208 […]

Delete all files in child tables

I have the following SQL tables: create table dbo.Media ( Id int identity not null constraint PK_Media_Id primary key clustered (Id), Created datetime not null, ) create table dbo.MediaFile ( MediaId int not null, FileId int not null ) create table dbo.[File] ( Id int identity not null constraint PK_File_Id primary key clustered (Id), Content […]

C# Connection String Without Windows Authentication Mode

I tried a lot but couldn’t solve this problem. I want just my connection sql in c# by sql server authentication mode. I don’t want windows authentication. When I enable windows authentication mode then my application does not work. What can I do? This my connection string: SqlConnection con = new SqlConnection(@”Data Source=myservername;Initial Catalog=mydatabesename;User Id=myuserId; […]

Finding values that matches max column in SQL server

I have a table that has the max months column like the one below: Category MaxMonths Title X 3 Beginner-1 X 6 Intermediate-1 X 12 Avance-1 X 999 Master-1 Y 3 Beginner-2 Y 6 Intermediate-2 Y 12 Avance-2 Y 999 Master-2 I also have another table with a number of months column like the one […]

Connecting to SQL Server with Windows authentication using NodeJs mssql

I need to connect to SQL Server using nodeJs. This is the connection string normally I used for .NET Data Source=DESKTOP-QPC8N68\SQLEXPRESS;Initial Catalog=ProjectX;Integrated Security=True I’m using the mssql npm package and my code as follows: app.get(‘/’, function (req, res) { var sql = require(“mssql”); var config = { server: ‘localhost\\SQLEXPRESS’, database: ‘ProjectX’, options: { trustedConnection: true […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.