Skip to content

Tag: sql-server

Unable to open BCP host data-file

Below is an example of the BCP Statement. I’m not accustomed to using BCP so your help and candor is greatly appreciated I am using it with a format file as well. If I execute from CMD prompt it works fine but from SQL I get the error. The BCP statement is all on one line and the SQL Server

Insert distinct values from one table into another table

So for each distinct value in a column of one table I want to insert that unique value into a row of another table. Any ideas as to how to go about this? Answer Whenever you think about doing something in a loop, step back, and think again. SQL is optimized to work with sets. You can do this using

how to convert date to a format `mm/dd/yyyy`

I’m having a sql table with date column named CREATED_TS which holds the dates in different format eg. as shown below Now I want to convert these to format mmddyyyy before as i am comparing the dates in WHERE clause of my SELECT query. I tried using but got the result as, I need the result as eg. 02/20/…

Sql Command Not Working

I wrote the following code, but nothing is being inserted into the database. I tried changing the SA password in the connection string to something incorrect and the code isn’t catching the exception. What am I doing wrong? Answer As stated by the OP in the comments. Once the try-catch was resolved it w…

Test for Upper Case – T-Sql

All, How can I check if a specified varchar character or entire string is upper case in T-Sql? Ideally I’d like to write a function to test if a character is upper case, then I can later apply that to a generic varchar. It should return false for non alphabetic characters. I am only interested in englis…