IF EXITS (SELECT *
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'PRIMARY KEY'
AND TABLE_NAME = '..... your table name ....'
AND TABLE_SCHEMA ='dbo' )
BEGIN
---- Your code here
2009/09/14
SQL - create stored procedure if not exists
IF NOT EXISTS(Select * from sysobjects where name = 'usp_UserSproc')
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE usp_UserSproc
(
@ID int = NULL --nullable input
)
AS
BEGIN
-- BLAH BLAH BLAH
END';
END
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE usp_UserSproc
(
@ID int = NULL --nullable input
)
AS
BEGIN
-- BLAH BLAH BLAH
END';
END
2009/08/25
MSSQL- use runas to login to sql server with windows authentication
For some situation, you will need to use remote computer to connect to different server and login the sql server by windows authentication. But good news, you can use the following technique so that you can just login to the specific sql server from local machine.
- Open cmdor create a short cut with the following path:
C:\WINNT\system32\runas.exe /user:domain\login "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe"
So you save your time by without having to connect to your remote computer ;)
Reporting Services- Thousand separator
With decimal:
Format(First(Fields!IRTotal.Value, "TDec"), "#,###0.00")
Without decimal:
Format(First(Fields!IRTotal.Value, "TDec"), "#,###0")
Format(First(Fields!IRTotal.Value, "TDec"), "#,###0.00")
Without decimal:
Format(First(Fields!IRTotal.Value, "TDec"), "#,###0")
2009/08/21
Reporting Services- Error [BC30494]
I am working on Report and I got this error:
error [BC30494] Line is too long.
Problem\Solution: If your table is too big will causes this error. There is a simple solution: rename all your text boxes to a short name, for example: textbox1234 - > t1234
If the above solution doesn't help, try to split the table into two.
Enjoy
error [BC30494] Line is too long.
Problem\Solution: If your table is too big will causes this error. There is a simple solution: rename all your text boxes to a short name, for example: textbox1234 - > t1234
If the above solution doesn't help, try to split the table into two.
Enjoy
2009/08/07
SQL- Stored procedure: list out all columns of a table
Sometimes, you need to create a temp table or whatever, you need to list out all the columns. If just only 2 or 3 columns sure that won't bother you, but if the table has 100 columns, its gonna kill you if you have to type everyone of it. So, here is the stored procedure for you. It will list out all columns of a table in one line and separate the columns with comma.
Usage: exec SP_ColName 'TABLENAME'
===
IF EXISTS (SELECT * FROM [sysobjects] WHERE [id] = OBJECT_ID(N'[dbo].[SP_ColName]'))
DROP PROCEDURE [SP_ColName]
GO
-- Usage: SP_ColName
Usage: exec SP_ColName 'TABLENAME'
===
IF EXISTS (SELECT * FROM [sysobjects] WHERE [id] = OBJECT_ID(N'[dbo].[SP_ColName]'))
DROP PROCEDURE [SP_ColName]
GO
-- Usage: SP_ColName
C# Is null or string is empty
I just found that there is a "new" thing to check the string is null or empty (asp.net 2.0)
old way:
if (var == string.Empty && var == null)
new way:
if (String.IsNullOrEmpty(var))
It looks cool right? Enjoy!
old way:
if (var == string.Empty && var == null)
new way:
if (String.IsNullOrEmpty(var))
It looks cool right? Enjoy!
Subscribe to:
Posts (Atom)