Having executed a DB deploy (from a VS SQL Server database project) on a local database, which failed, the database has been left in a state where it has single user mode left on (the deploy runs as …
Tag: sql-server
Calling Stored Procedure while passing parameters from Access Module in VBA
I am working in Access 2010 with a Microsoft SQL Server 2008 backend. I have a stored procedure that inserts new values(supplied by the parameters) into a table. The values assigned to the parameters are obtained from files stored in a folder. The Windows File System is used to scan a particular folder to mak…
SQL Server: how to select records with specific date from datetime column
I am pretty new to SQL and hope someone here can help me with this: I have a table with one column dateX formatted as datetime and containing standard dates. How can I select all records from this table where this dateX equals a certain date, e.g. May 9, 2014 ? I tried the following but this returns nothing e…
Execute query using C# [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 8 years ago. Improve this question I am trying to execute some SQL code, connected directly to my database, but I don’t k…
Set column to a concatenated value from another table
I have 2 tables in SQL Server 2008: Address: nameid | e-mail ————— 1 | xyz@abc.com 2 | fgh@asdf.com 3 | 123@doremi.com Member: nameid | memberid ————— 1 | …
How to create copy of database using backup and restore
Using SQL Server Management Studio 2012, I’m trying to create a copy of a local database. I found a few variants of solution. One of them – backup and restore database as new one – HERE. Currently create database backup with name Rewards2_bak. This copy of file place in to system catalog C:P…
How to replace empty spaces with NULL
I have a column in sql server 2012 which contain white spaces. I want to replace these empty spaces with NULL. I have written the following query but its not working. How to achieve the above functionality. Thanks in advance. Answer Use nullif
Is there a T-SQL command that checks whether the object to which a synonym refers exists and is valid?
I’m trying to test if all synonyms on a database refer to valid objects, using the SQL batch script below, as part of a clean-up effort on our databases. This script just performs a query against the synonym, and printing out any errors it encounters. This works fine on views and tables, but not on spro…
Finding max value of multiple columns in Sql
How can I find maximum value on multiple columns. This is what I have so far. This code is giving me the error: Incorrect syntax near ‘maxval’. Answer Are you simply looking for GREATEST? However GREATEST Returns NULL when a value is NULL, so you might want to care about this, too. For instance: E…
Printing integer variable and string on same line in SQL
Ok so I have searched for an answer to this on Technet, to no avail. I just want to print an integer variable concatenated with two String variables. This is my code, that doesn’t run: It seems like such a basic feature, I couldn’t imagine that it is not possible in T-SQL. But if it isn’t po…