How to find a text inside SQL Server procedures / triggers?

I have a linkedserver that will change. Some procedures call the linked server like this: [10.10.100.50].dbo.SPROCEDURE_EXAMPLE. We have triggers also doing this kind of work. We need to find all places that uses [10.10.100.50] to change it. In SQL Server Management Studio Express, I didn’t find a feature like “find in whole database” in Visual … Read more

How to ALTER multiple columns at once in SQL Server

I need to ALTER the data types of several columns in a table. For a single column, the following works fine: ALTER TABLE tblcommodityOHLC ALTER COLUMN CC_CommodityContractID NUMERIC(18,0) But how do I alter multiple columns in one statement? The following does not work: ALTER TABLE tblcommodityOHLC ALTER COLUMN CC_CommodityContractID NUMERIC(18,0), CM_CommodityID NUMERIC(18,0) 13 Answers 13

How to check existence of user-define table type in SQL Server 2008?

I have a user-defined table type. I want to check it’s existence before editing in a patch using OBJECT_ID(name, type) function. What type from the enumeration should be passed for user-defined table types? N’U’ like for user defined table doesn’t work, i.e. IF OBJECT_ID(N’MyType’, N’U’) IS NOT NULL 5 Answers 5

Conversion failed when converting date and/or time from character string while inserting datetime

I was trying to create a table as follows, create table table1(date1 datetime,date2 datetime); First I tried inserting values as below, insert into table1 values(’21-02-2012 6:10:00 PM’,’01-01-2001 12:00:00 AM’); It has given error saying, Cannot convert varchar to datetime Then I tried below format as one of the post suggested by our stackoverflow, insert into … Read more

Can I create a named default constraint in an add column statement in SQL Server?

In SQL Server, I have a new column on a table: ALTER TABLE t_tableName ADD newColumn NOT NULL This fails because I specify NOT NULL without specifying a default constraint. The table should not have a default constraint. To get around this, I could create the table with the default constraint and then remove it. … Read more