SQL Server datetime LIKE select?

in MySQL select * from record where register_date like ‘2009-10-10%’ What is the syntax in SQL Server? Thank you.

SQL Server JDBC Error on Java 8: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption

I am getting the following error when connecting to a SQL Server database using version the Microsoft JDBC Driver: com.microsoft.sqlserver.jdbc.SQLServerException: 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. ClientConnectionId:98d0b6f4-f3ca-4683-939e-7c0a0fca5931”. We recently upgraded our […]

Execute multiple SQL commands in one round trip

I am building an application and I want to batch multiple queries into a single round-trip to the database. For example, lets say a single page needs to display a list of users, a list of groups and a list of permissions. So I have stored procs (or just simple sql commands like “select * […]

How can i get the list of tables in the stored procedure

There are lot of tables and sp in the db. I find the tables name which are used in the specific sp (stored procedure). sp_depends %sp_name% not give the desire result. i am also used INFORMATION_SCHEMA.TABLES,INFORMATION_SCHEMA.ROUTINES tables . but the result is not full fill my requirment.

SQL Query to find the last day of the month

I need to find the last day of a month in the following format: “2013-05-31 00:00:00:000” Anybody please help out.

Return ID on INSERT?

I have an INSERT query and I want the DB to return the ID of the row I just inserted. sqlString = “INSERT INTO MagicBoxes (OwnerID, Key, Name, Permissions, Active, LastUpdated) VALUES (@OwnerID, @BoxKey, @BoxName, 0, 1, @Date) SET @ID = SCOPE_IDENTITY();”; cmd = new SqlCommand(sqlString, con); cmd.Parameters.AddWithValue(“@OwnerID”, OwnerID); cmd.Parameters.AddWithValue(“@BoxKey”, BoxKey); cmd.Parameters.AddWithValue(“@BoxName”, BoxName); cmd.Parameters.AddWithValue(“@Username”, Username); […]

Conditional SQL ORDER BY ASC/DESC for alpha columns

Writing a stored procedure in MS SQL Server 2008 R2, I want to avoid using DSQL… I would like the sort method (ASC or DESC) to be conditional. Now, with a numeric column I would simply use a case statement and negate the value to emulate ASC or DESC… That is: … ORDER BY CASE […]

How to insert a record and return the newly created ID using a single SqlCommand?

I’m using an SqlCommand object to insert a record into a table with an autogenerated primary key. How can I write the command text so that I get the newly created ID when I use the ExecuteScalar() method?

SQL Server date format function

SELECT CONVERT(VARCHAR(10), GETDATE(), 105) This query return the date in the [DD-MM-YYYY] format as varchar. I need the same format in datetime datatype in sql server. Pls help me out

How can sanitation that escapes single quotes be defeated by SQL injection in SQL Server?

To start this off, I am well aware that parameterized queries are the best option, but I am asking what makes the strategy I present below vulnerable. People insist the below solution doesn’t work, so I am look for an example of why it wouldn’t. If dynamic SQL is built in code using the following […]

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