How to perform “select top 1 x from table” statement in spark sql

I am facing problem converting bellow query in spark-sql in pyspark SQL-server query is coalesce((Select top 1 f2.ChargeAmt from Fact_CMCharges f2 where f2.BldgID = f.BldgID and f2.LeaseID = f.LeaseID and f2.IncomeCat = f.IncomeCat and f2.Period < f.Period and f2.ActualProjected = ‘Lease’ order by f2.Period desc),0) as Charge I did not find replacing key word of […]

How to get information from SQL table with php

So i’ve created a database on SQL, i’m trying to get information (id,title and date)out of one of the tables i need and make an html element of it but when i run the function nothing happens. <?php function getTitles (){ $conn; $sql=’SELECT * FROM `thumbnails`’; $statement = $conn->prepare($sql); $statement->bindValue(“:title_id”,$title_id); $statement->execute(); $titles = $statement->fetchAll(); $output=”; […]

“Call to undefined function sqlsrv_connect()” in Wamp, drivers installed

This question already has an answer here: Call to undefined function sqlsrv_connect() with WAMP 3 answers

how to use other, previous, values to create a new value

This is my first post having found so much of what I have needed previously by searching this site. I can’t find an answer to this one, so here we go…I have a table containing the number of customers for around 40 organisations listed by month, sample as follows: Month OrgID Cust 201509 G85001 12731 […]

SQL with input condition

I have a customer table-firstname,lastname,gender,salary. I am creating a stored procedure with 5 input parameters: @FN, @LN, @GNDR, @SLRY and @TYPE. Now, if @type=0 and @FN=’SAM’ – then, it should insert a new record in the table, if ‘SAM’ is already existing in the table. if @type=1 and @FN=’SAM’ – then, it should delete a […]

Can the result of this 'from' be reused?

I saw this the following sql in my friend’s .sql scripts: from ( ….. ) a select col1,col2 from a select col3 from a where … My friend said the sql in the ‘from’ will be excuted only once and its result will be reused when ‘a’ is called. I just want to confirm is […]

how to get filename without extension using xp_dirtree

I have used xp_dirtree to get list of filenames from remote server path folder. the files are with extensions .bak I do not want the get the filename with extension .bak for eg: filename Sales_backup_2016_10_09_213002_7679353.bak needs to get Sales_backup_2016_10_09_213002_7679353. I did search many blags for this but no luck. please can anyone suggest me how […]

SQL Server and Hibernate – datetime2 vs varbinary

Hibernate saves the older Java Date objects as a datetime2(7) in SQL Server, and Hibernate saves the newer Java LocalDateTime objects as varbinary(255) in SQL Server. Are there any issues with performance, for instance searching greater than/equal to or less than/equal to datetimes using varbinary(255) vs datetime2(7)? I’m using Hibernate 5 through GORM in Grails […]

Use SQL Server to publish to rabbitmq via amqp

I am looking for specific help setting up message types/contracts/queues and EA to post notifications of SQL table update/inserts to an existing RabbitMQ system. The destination quese already exist. SQL-to-SQL documentation exists, but not going SQL-to-RabbitMQ.

TextWrangler SQL Formatter PHP Script

I am trying to format sql using Text Wrangler. I have saved a php file in the location ~/Library/Application Support/TextWrangler/Text Filters. However my formatter is working, but its converting the table names to uppercase. I don’t want to change the case of tables. Following is my php script: #!/usr/bin/php <?php /** * BBEdit SQL format […]

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