Posts Tagged ‘SQL Server’

Sql Server: Must declare the scalar variable

When one of asp.net project was in develop stage, we always got the exception ‘Must declare the scalar variable  “@variableName” ‘
I checked and searched from internet, about this issue, there have been many different reasons and solutons. But seems all of them are not fit our case.
I had to check by myself. I focused [...]

Leave a Comment

Reset Identity column in SQL Server

For identity column in SQL Server, we have a command to easy to control it!
DBCC CHECKIDENT
1 : Resets the Identity value for the Customer table to 0 so that the next record added starts at 1.
     DBCC CHECKIDENT(’Customer’, RESEED, 0)
2: Check current identify value:
    DBCC CHECKIDENT (’tablename’, NORESEED)
3: Set the next ID start from [...]

Leave a Comment

sql server create table script samples

****BEGIN SQL QUERY***
if exists (select * from dbo.sysobjects where id = object_id(N’dbo.tbl_Actions’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
drop table dbo.tbl_Actions
GO
if exists (select * from dbo.sysobjects where id = object_id(N’dbo.tbl_Authentications’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
drop table dbo.tbl_Authentications
GO
****BEGIN SQL QUERY***
if exists (select * from dbo.sysobjects where id = object_id(N’dbo.tbl_Actions’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
drop table dbo.tbl_Actions
GO
if exists (select [...]

Leave a Comment

How to SORT a System.Collections.Generic.List

I have to Sort a List of Class
I have 3 Properties in my Class (EX ID,Name,Age)
In my List i have 10 objects of <Class> added
I need to sort By Id or By Name or by Age like DataView Sort.is it possible ?
Please enligten me
Thanx,
How to SORT a System.Collections.Generic.List
I have to Sort a List of Class
I [...]

Leave a Comment

sql server 插入汉字问题

SQL SERVER 2005 比SQL SERVER 2000增加了很多新特性,我没仔细研究就开始使用SQL SERVER 2005了。遇到的问题还真不少。
SQL SERVER2005中发现不能用vachar()存汉字了(SQL SERVER 2000创建的数据库导入SQL SERVER 2005除外),改用ncachar()了,但写起程序的时候,发现插入的汉字都变成了??,直接用T-SQL语句执行插入,也是一样,在管理器中直接插 入却可以显示汉字。
解决:T-SQL语句中在要要存储的字符前加上N。
如:insert into 表名 (字段名) values(N”內容”);

Leave a Comment