If I use an update statement in an update trigger, does that update statement in update trigger causes fire trigger? Answer Make sure your database property for RECURSIVE_TRIGGERS is set to off (which is the default anyway) so that it cannot be fired recursively. http://technet.microsoft.com/en-us/library/ms1…
Combining (concatenating) date and time into a datetime
Using SQL Server 2008, this query works great: Gives me two columns like this: I’m trying to combine them into a single datetime using the plus sign, like this: I’ve looked on about ten web sites, including answers on this site (like this one), and they all seem to agree that the plus sign should …
How do I get constraints on a SQL Server table column
I have a column called MealType (VARCHAR) in my table with a CHECK constraint for {“Veg”, “NonVeg”, “Vegan”} That’ll take care of insertion. I’d like to display these options for selection, but I couldn’t figure out the SQL query to find out the constraint…
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
Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column
I’m trying to insert a large CSV file (several gigs) into SQL Server, but once I go through the Import Wizard and finally try to import the file I get the following error report: Executing (Error) Messages Error 0xc02020a1: Data Flow Task 1: Data conversion failed. The data conversion for column “…
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
T-SQL – compare strings char by char
I need to compare two strings character by character using T-SQL. Let’s assume i have twor strings like these: 123456789 212456789 Every time the character DO NOT match, I would like to increase …
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/…
Temp sequence in postgres view
I have a table that I order a certain way often. That ordering is the basis of a derived column we can call rank. If I query the entire table, I can have the database calculate that rank for me: This yields useful results like: With that result set I can determine the rank of any foo. However this requires
Command.ExecuteScalar always return null while Stored Procedure in Management Studio runs fine
I have the following SQL stored procedure with one input parameter and one out parameter. CREATE PROCEDURE [dbo].[spCanUserEdit] ( @username nvarchar(255) ) AS BEGIN SET NOCOUNT ON; DECLARE @CanEdit …