Friday, March 23, 2012
How to increment a column with varchar data type
is there any method for incrementing the varchar field
i have an emp table with columns
create table emprecord(eno varchar(10), ename varchar(20))
i cant give eno column with identity field because identity column must
be of data type int, bigint, smallint, tinyint, or decimal or numeric
insert into emprecord values ('MH1001','satish')
insert into emprecord values ('MH1002','rehman')
my problem is there any method --when i pass only the ename the eno
field should be automatically incremented as MH1003 --each time it has
to check for the highest eno ie.., MH1002 is my highest eno in the
table emprecord
i think there is sequence option in MS Sql server-- if so how to use
sequence
pls help me
thanks
satishTry a search about "SQL Server identity values", but it supports integer
values only. You might need to make appropriate modifications on your table.
Martin C K Poon
Senior Analyst Programmer
====================================
"satish" <satishkumar.gourabathina@.gmail.com> ?
news:1145000321.252703.52230@.t31g2000cwb.googlegroups.com ?...
> hi,
> is there any method for incrementing the varchar field
> i have an emp table with columns
> create table emprecord(eno varchar(10), ename varchar(20))
> i cant give eno column with identity field because identity column must
> be of data type int, bigint, smallint, tinyint, or decimal or numeric
> insert into emprecord values ('MH1001','satish')
> insert into emprecord values ('MH1002','rehman')
> my problem is there any method --when i pass only the ename the eno
> field should be automatically incremented as MH1003 --each time it has
> to check for the highest eno ie.., MH1002 is my highest eno in the
> table emprecord
> i think there is sequence option in MS Sql server-- if so how to use
> sequence
>
> pls help me
> thanks
> satish
>|||You could use a computed column instead|||satish
create table #t
(
rowid int not null identity(1,1) primary key,
empno AS 'MH'+CAST(rowid AS VARCHAR(10)),
empname VARCHAR (50)
)
insert into #t(empname) VALUES ('Smith')
insert into #t (empname)VALUES ('Clinton')
insert into #t (empname) VALUES ('Brown')
select empno,empname from #t
drop table #t
"satish" <satishkumar.gourabathina@.gmail.com> wrote in message
news:1145000321.252703.52230@.t31g2000cwb.googlegroups.com...
> hi,
> is there any method for incrementing the varchar field
> i have an emp table with columns
> create table emprecord(eno varchar(10), ename varchar(20))
> i cant give eno column with identity field because identity column must
> be of data type int, bigint, smallint, tinyint, or decimal or numeric
> insert into emprecord values ('MH1001','satish')
> insert into emprecord values ('MH1002','rehman')
> my problem is there any method --when i pass only the ename the eno
> field should be automatically incremented as MH1003 --each time it has
> to check for the highest eno ie.., MH1002 is my highest eno in the
> table emprecord
> i think there is sequence option in MS Sql server-- if so how to use
> sequence
>
> pls help me
> thanks
> satish
>|||there are no identity columns defined in my table in that case how to
do
this is my table
create table emprecord(eno varchar(10), ename varchar(20))
i always pass only ename|||It's better to break empno into empPrefix (varchar(2)) and empSerial (int).
or, if the table structure cannot be modified, I will opt to use stored
procedure (and/or other programming means).
create table #MyTempEmpRecord06041402
(
empno varchar(10),
empname VARCHAR (50)
)
go
-- Assumes that @.myEmpnoPrefix is always having 2 characters
create procedure #MyInsertEmpname06041402
@.myEmpnoPrefix varchar(2),
@.myEmpname varchar(50)
as
insert #MyTempEmpRecord06041402
select @.myEmpnoPrefix
+ (select convert(varchar(8), convert(int, isnull(max(substring(empno,
1 + len(@.myEmpnoPrefix), 8)), '0')) + 1) as MySerial
from #MyTempEmpRecord06041402
where left(empno, len(@.myEmpnoPrefix)) = @.myEmpnoPrefix)
as empno,
@.myEmpname as empname
go
exec #MyInsertEmpname06041402 'MH', 'Smith'
exec #MyInsertEmpname06041402 'MH', 'Clinton'
exec #MyInsertEmpname06041402 'MP', 'Smith'
exec #MyInsertEmpname06041402 'MP', 'Brown'
exec #MyInsertEmpname06041402 'MH', 'Brown'
go
select * from #MyTempEmpRecord06041402
go
drop procedure #MyInsertEmpname06041402
go
drop table #MyTempEmpRecord06041402
Martin C K Poon
Senior Analyst Programmer
====================================
"satish" <satishkumar.gourabathina@.gmail.com> ?
news:1145007066.106515.192790@.t31g2000cwb.googlegroups.com ?...
> there are no identity columns defined in my table in that case how to
> do
> this is my table
> create table emprecord(eno varchar(10), ename varchar(20))
> i always pass only ename
>
Monday, March 12, 2012
How to import mysql data into SQL Server 2000 ?
I have a *.sql backup file, is there any method to import the backup into
SQL Server 2000 ? I cannot open it in the SQL Query Analyzer.
Thanks a lot !Hi,
That is actually a dump file of MYSQL. You cant use that in SQL Server
directly. Ways to transfer data from MYSQL to SQL server is given below:-
1. DTS
2. Generated comma seperated text file in MYSQL and use BCP IN / to load it.
Better and easiest option is to use DTS to copy data between
Thanks
Hari
MCDBA
<.> wrote in message news:OWZ8OZ5QEHA.2404@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> I have a *.sql backup file, is there any method to import the backup into
> SQL Server 2000 ? I cannot open it in the SQL Query Analyzer.
> Thanks a lot !
>
How to import mysql data into SQL Server 2000 ?
I have a *.sql backup file, is there any method to import the backup into
SQL Server 2000 ? I cannot open it in the SQL Query Analyzer.
Thanks a lot !Hi,
That is actually a dump file of MYSQL. You cant use that in SQL Server
directly. Ways to transfer data from mysql to SQL server is given below:-
1. DTS
2. Generated comma seperated text file in mysql and use BCP IN / to load it.
Better and easiest option is to use DTS to copy data between
Thanks
Hari
MCDBA
<.> wrote in message news:OWZ8OZ5QEHA.2404@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> I have a *.sql backup file, is there any method to import the backup into
> SQL Server 2000 ? I cannot open it in the SQL Query Analyzer.
> Thanks a lot !
>
How to import mysql data into SQL Server 2000 ?
I have a *.sql backup file, is there any method to import the backup into
SQL Server 2000 ? I cannot open it in the SQL Query Analyzer.
Thanks a lot !
Hi,
That is actually a dump file of MYSQL. You cant use that in SQL Server
directly. Ways to transfer data from MYSQL to SQL server is given below:-
1. DTS
2. Generated comma seperated text file in MYSQL and use BCP IN / to load it.
Better and easiest option is to use DTS to copy data between
Thanks
Hari
MCDBA
<.> wrote in message news:OWZ8OZ5QEHA.2404@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> I have a *.sql backup file, is there any method to import the backup into
> SQL Server 2000 ? I cannot open it in the SQL Query Analyzer.
> Thanks a lot !
>
Friday, February 24, 2012
How to identify which all SPs are accessing a given table ?
I don't know if I am in the right section of the forum. Please help me with this :
Is there any system stored procedure or any other method to identify the list of all stored procedures that are using a particular table in my database.
Thanks
Prasad P
Hi,
the only reliable method to get the information is to search the Information Schemas for the information, there is an article about sp_depends which sounds like you would get reliable information from it, but you don′t. I didn′t check the behaviour in SQL2k5, but check this article to get deeper information:
http://b.wunder.home.comcast.net/16509.htm
HTH, Jens Suessmeyer.
|||Check out my blog site:http://blogs.claritycon.com/blogs/the_englishman/archive/2006/02/09/197.aspx
After having the same problem, I wrote a blog containing a stored procedure which searches stored procedures for a text string using the syscomments system table (which stores the stored proc definitions). If you pass the table name into this procedure, it should get you in the correct direction.
Let me know if that solves your problem, or whether you need more assistance.
HTH|||? No, there's nothing built in. A quick and dirty way of figuring it out is: SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TEXT LIKE '%YourTableName%' This does have some issues due to especially large routines and routines that make use of dynamic SQL and concatenate names, but it may give you some indication. -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <Prasad Peesapati@.discussions..microsoft.com> wrote in message news:bdc2238e-c590-47ff-927a-5660b2f552db@.discussions.microsoft.com... I don't know if I am in the right section of the forum. Please help me with this : Is there any system stored procedure or any other method to identify the list of all stored procedures that are using a particular table in my database. Thanks Prasad P