SQL Declare的使用
1.虽然数据库中的License定义为int,但如果如下写法,会出现错误
declare @licenseId int select @licenseId=LicenseId from License where Name='ABC' print 'LicenseId:'+@licenseId
错误提醒如下:
修改方法如下:
declare @licenseId int select @licenseId=LicenseId from License where Name='ABC' print 'LicenseId:'+cast(@licenseId as varchar(50))
2.
declare @licenseId int select @licenseId=LicenseId from TableA where Name='ABC' INSERT INTO TableB (ColumnA,ColumnB,ColumnC,ColumnD,ColumnE,ColumnF) VALUES('ColumnA','ColumnB','ColumnC',@licenseId,GETDATE(),GETDATE())
本文来自博客园,转载请注明原文链接:https://www.cnblogs.com/keeplearningandsharing/p/15323347.html