I want my autonumbered column to start at a particular value because I am importing records into a table that has values in it already.
Basically, I have this table, smsysrecnum, that stored the last used sequence number for all user tables in the database.
Here's the entire query:
USE SDE
GO...
I'd like to use a value from another table to set the seed value for a field in a table variable.
This on its own parses ok:
--Variable to set the MU.Sequence field.
DECLARE @Seq int
SET @Seq = (SELECT (RECNUM + 1) FROM SDE.dbo.SMSYSRECNUM WHERE Name = '_COMPANY_')
And this code...
Does this look better?
USE SDE
GO
--Variable to set the EBU.Sequence field.
DECLARE @Seq int
--Table variable for EBU data.
declare @tmpEBU table (
NewSeq int IDENTITY(1001,1),
Name nvarchar (30)
)
--Populate the record number table.
INSERT SDE.dbo.smsysrecnum (Name, RecNum)
VALUES...
I need some help figuring out what I am doing wrong. I am trying to migrate data from one system to another, and I want to assign an incrementing number to a field, but I can't seem to nail down the particulars. I am starting to think I need a stored procedure to increment the field. Please let...
I'm not very familiar with DTS, but thought it was the right tool for this job. I am trying to import data from one database to another, and the target table has a primary key called Sequence (int). I wrote a lookup that says:
select max (sequence) + 1
from Customer
...and the ActiveX script...
Thanks Otto. You got me headed down the right path. My secondary IF... condition was looking at the wrong field. I updated it and it now works properly.
I've got the following function defined:
USE MagicTSD
GO
ALTER FUNCTION dbo.ProjectTime_GetProjectID (@WONum int)
RETURNS nvarchar(40)
BEGIN
DECLARE @ProjID nvarchar(40)
SET @ProjID = 'No ID'
IF ( NOT (SELECT [HDNUM] FROM [_SMDBA_].[_WORKORD_] as W WHERE W.[SEQUENCE] = @WONum) IS NULL)...
Excel 2000, Access 2000
I am trying to import a spreadsheet to a table. The spreadsheet column headings are named the same as the target table. There are no spaces in any of the column names. The target table contains an autonumber field (not sure if this is the cause of the issue or not). The...
http://tek-tips.com/faqs.cfm?fid=4233
I'm attempting to use the function listed in the FAQ above to concatenate fields across two tables into a single field in an append query. I am not too sure of the syntax I need to use.
My tables look like this:
tblManualInstall:
Sequence
OldSerialNum...
Thanks DNG.
I ran this:
select max (datalength (mytextfield)) from mytable
and found that the largest datalength is 8758 characters, so it looks like I'll need a few of those queries to get the job done.
DNG,
Wow. That is very good to know. Should I have a second query that reads as follows?
SELECT SUBSTRING (mytextfield, 2001, datalengeth(mytextfield)) from mytable
Borris,
The code I posted above is sufficient for me because I was in fact trying to get the entire text of the field. I needed to know the position of the last character to pass to the substring function, and as it turns out, the datalengeth function was all I was missing. Thanks to you and...
Thanks for getting me on the right track, DotNetGnat. Here's the code I wound up using:
SELECT SUBSTRING (mytextfield, 1, datalengeth(mytextfield)) from mytable
kaht,
When I try the above statement, I get the following message in QA:
Server: Msg 8116, Level 16, State 2, Line 5
Argument data type text is invalid for argument 1 of rtrim function.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.