String or binary data would be truncated.

  • Hi All

    I want to retrieve information from different servers using linked servers.When I run the following query, I get an error:

    String or binary data would be truncated.

    the query is as follows:

    --SET ANSI_WARNINGS On

     

    DECLARE

    @count1 int

    DECLARE

    @count2 int

    DECLARE

    @ServerName varchar(300)

    DECLARE

    @Query1 nvarchar(2000)

    DECLARE

    @Query2 nvarchar(2000)

    DECLARE

    @Query3 nvarchar(2000)

    set

    @count1 =0

    set

    @count2 =(Select max(ServerID) from dbo.Server_Lookup where Status = 'Active')

    While

    @count1 <= @count2

    begin

    set

    @count1=@count1 +1

    set

    @ServerName =(Select distinct ServerName from dbo.Server_Lookup where Status = 'Active' AND serverID = +@count1)

    set

    @Query2 = 'insert into dbo.Database_Logins'

    set

    @Query3 = @Query2 + ' SELECT * FROM OPENQUERY ('+@ServerName +','+''' SET FMTONLY OFF exec master.dbo.sp__DatabaseLogins'')'

    print

    @Query3

    exec

    (@Query3)

    end

    Any idea on how I can bypass it??THANK YOU!! your help would be much appreciated!!

    Anchelin

     

     

     

     

     

  • Make sure your columns in dbo.Database_Logins are big enough to hold the result set from sp_DatabaseLogins.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply